Merge pull request #2016 from SiboVG/unstable
Fix some issues in software updater
This commit is contained in:
commit
cecd8b881d
@ -358,8 +358,15 @@ public class UpdateInfoRetriever {
|
|||||||
// If the loop is still going until this condition, you have the situation where tag1 is e.g.
|
// If the loop is still going until this condition, you have the situation where tag1 is e.g.
|
||||||
// '15.03' and tag2 '15.03.01', so tag is in that case the more recent version.
|
// '15.03' and tag2 '15.03.01', so tag is in that case the more recent version.
|
||||||
if (i >= tag1Split.length) {
|
if (i >= tag1Split.length) {
|
||||||
|
// Tag 1 is e.g. '15.03' and tag2 '15.03.01', so tag2 is the more recent version
|
||||||
|
if (tag2Split[i].matches("\\d+")) {
|
||||||
return ReleaseStatus.OLDER;
|
return ReleaseStatus.OLDER;
|
||||||
}
|
}
|
||||||
|
// Tag 1 is e.g. '15.03' and tag2 '15.03.beta.01', so tag1 is the more recent version (it's an official release)
|
||||||
|
else {
|
||||||
|
return ReleaseStatus.NEWER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int tag1Value = Integer.parseInt(tag1Split[i]);
|
int tag1Value = Integer.parseInt(tag1Split[i]);
|
||||||
@ -389,6 +396,8 @@ public class UpdateInfoRetriever {
|
|||||||
// a text, e.g. '20.01'
|
// a text, e.g. '20.01'
|
||||||
if (tag2Split[i].matches("\\d+")) {
|
if (tag2Split[i].matches("\\d+")) {
|
||||||
return ReleaseStatus.OLDER;
|
return ReleaseStatus.OLDER;
|
||||||
|
} else if (tag1Split[i].matches("\\d+")) {
|
||||||
|
return ReleaseStatus.NEWER;
|
||||||
}
|
}
|
||||||
|
|
||||||
String message = String.format("Unrecognized release tag format, tag 1: %s, tag 2: %s", tag1, tag2);
|
String message = String.format("Unrecognized release tag format, tag 1: %s, tag 2: %s", tag1, tag2);
|
||||||
@ -410,6 +419,12 @@ public class UpdateInfoRetriever {
|
|||||||
return ReleaseStatus.LATEST;
|
return ReleaseStatus.LATEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the release tag is malformed (e.g. empty, or containing invalid entries, such as negative numbers
|
||||||
|
* or unknown tags)
|
||||||
|
* @param tagSplit the tag split by '.' or '-'
|
||||||
|
* @throws UpdateCheckerException if the tag is malformed
|
||||||
|
*/
|
||||||
private static void checkMalformedReleaseTag(String[] tagSplit) throws UpdateCheckerException {
|
private static void checkMalformedReleaseTag(String[] tagSplit) throws UpdateCheckerException {
|
||||||
if (tagSplit.length == 0) {
|
if (tagSplit.length == 0) {
|
||||||
String message = "Zero-length tag";
|
String message = "Zero-length tag";
|
||||||
|
@ -185,6 +185,21 @@ public class UpdateInfoTest extends BaseTestCase {
|
|||||||
assertEquals(UpdateInfoRetriever.ReleaseStatus.OLDER,
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.OLDER,
|
||||||
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("22.02.beta.01", "22.02.02"));
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("22.02.beta.01", "22.02.02"));
|
||||||
|
|
||||||
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.OLDER,
|
||||||
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("22", "22.02.beta.01"));
|
||||||
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.NEWER,
|
||||||
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("22.02", "22.02.beta.01"));
|
||||||
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.NEWER,
|
||||||
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("22.02.01", "22.02.beta.01"));
|
||||||
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.OLDER,
|
||||||
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("22", "22.02.beta.01"));
|
||||||
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.NEWER,
|
||||||
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("22.03", "22.02.beta.01"));
|
||||||
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.OLDER,
|
||||||
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("22.01", "22.02.beta.01"));
|
||||||
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.NEWER,
|
||||||
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("22.02.02", "22.02.beta.01"));
|
||||||
|
|
||||||
assertEquals(UpdateInfoRetriever.ReleaseStatus.NEWER,
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.NEWER,
|
||||||
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("22.02.RC.01", "22"));
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("22.02.RC.01", "22"));
|
||||||
assertEquals(UpdateInfoRetriever.ReleaseStatus.OLDER,
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.OLDER,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user