|
@@ -41,6 +41,7 @@ import java.util.HashMap;
|
41
|
41
|
import java.util.List;
|
42
|
42
|
import java.util.Map;
|
43
|
43
|
import java.util.Objects;
|
|
44
|
+import java.util.function.Function;
|
44
|
45
|
import java.util.regex.Matcher;
|
45
|
46
|
import java.util.regex.Pattern;
|
46
|
47
|
import java.util.stream.Collectors;
|
|
@@ -58,6 +59,9 @@ import static com.dmdirc.ClientModule.GlobalConfig;
|
58
|
59
|
public class NightlyChecker implements UpdateCheckStrategy {
|
59
|
60
|
|
60
|
61
|
private static final Logger LOG = LoggerFactory.getLogger(NightlyChecker.class);
|
|
62
|
+ /** Name matching regex. */
|
|
63
|
+ private final Pattern pattern = Pattern.compile(
|
|
64
|
+ "^(.*?)-([^-]+(-[0-9]+-g[0-9a-f]+)?)(-SNAPSHOT).jar?$");
|
61
|
65
|
/** The URL to request to check for updates. */
|
62
|
66
|
private static final String UPDATE_URL = "https://nightlies.dmdirc.com/json/latest";
|
63
|
67
|
/** The update channel to check for updates on. */
|
|
@@ -74,12 +78,12 @@ public class NightlyChecker implements UpdateCheckStrategy {
|
74
|
78
|
@Inject
|
75
|
79
|
public NightlyChecker(@GlobalConfig final AggregateConfigProvider configProvider,
|
76
|
80
|
final Downloader downloader) {
|
77
|
|
- configProvider.getBinder().bind(this, DMDircCheckStrategy.class);
|
|
81
|
+ configProvider.getBinder().bind(this, NightlyChecker.class);
|
78
|
82
|
this.downloader = downloader;
|
79
|
83
|
}
|
80
|
84
|
|
81
|
85
|
/**
|
82
|
|
- * Sets the channel which will be used by the {@link DMDircCheckStrategy}.
|
|
86
|
+ * Sets the channel which will be used by the {@link NightlyChecker}.
|
83
|
87
|
*
|
84
|
88
|
* @param channel The new channel to use
|
85
|
89
|
*/
|
|
@@ -110,8 +114,7 @@ public class NightlyChecker implements UpdateCheckStrategy {
|
110
|
114
|
resultsList.stream()
|
111
|
115
|
.filter(Objects::nonNull) //This is incase the JSON is broken
|
112
|
116
|
.forEach(e -> {
|
113
|
|
- final Matcher matcher = Pattern.compile(
|
114
|
|
- "^(.*?)-([^-]+(-[0-9]+-g[0-9a-f]+)?)(-SNAPSHOT).jar?$").matcher(e.getName());
|
|
117
|
+ final Matcher matcher = pattern.matcher(e.getName());
|
115
|
118
|
if (matcher.matches()) {
|
116
|
119
|
e.setOtherName(matcher.group(1));
|
117
|
120
|
e.setVersion(new Version(matcher.group(2)));
|
|
@@ -119,7 +122,7 @@ public class NightlyChecker implements UpdateCheckStrategy {
|
119
|
122
|
}
|
120
|
123
|
});
|
121
|
124
|
final Map<String, NightlyResult> resultsMap = resultsList.stream()
|
122
|
|
- .collect(Collectors.toMap(NightlyResult::getOtherName, n -> n));
|
|
125
|
+ .collect(Collectors.toMap(NightlyResult::getOtherName, Function.identity()));
|
123
|
126
|
final Map<UpdateComponent, UpdateCheckResult> returns = new HashMap<>();
|
124
|
127
|
components.forEach(e -> {
|
125
|
128
|
if (resultsMap.containsKey(e.getName())) {
|