Skip to content

Commit

Permalink
Remove support for downgrading launcher version via auto-update
Browse files Browse the repository at this point in the history
  • Loading branch information
tibetiroka committed Jun 10, 2023
1 parent bd969f0 commit f35ddb2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static boolean areUpdatesSupported() {
* @since 0.0.1
*/
public static boolean needsUpdate() throws GitAPIException, URISyntaxException {
return findLatest().filter(s -> !VersioningUtils.isSameRelease(s, (String) AppConfiguration.DEFAULT_CONFIGURATION.get("launcher.version"))).isPresent();
return findLatest().filter(s -> VersioningUtils.isNewerRelease((String) AppConfiguration.DEFAULT_CONFIGURATION.get("launcher.version"),s)).isPresent();
}

/**
Expand Down
32 changes: 23 additions & 9 deletions src/main/java/tibetiroka/esmanager/utils/VersioningUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,32 @@
* @since 0.0.1
*/
public class VersioningUtils {
public static boolean isSameRelease(String first, String second) {
if(first.startsWith("v")) {
first = first.substring("v".length());
}
if(second.startsWith("v")) {
second = second.substring("v".length());
}
return first.equalsIgnoreCase(second);
/**
* Checks whether the second release is newer than the first one. It is newer if the semantic version number is greater.
*
* @param first The first release
* @param second The second release
* @return True if the second is newer
* @since 1.0.0
*/
public static boolean isNewerRelease(@NotNull String first, @NotNull String second) {
return semVerComparator().compare(first, second) > 0;
}

/**
* Checks whether the two releases are the same. They are the same if they describe the same semantic version number.
*
* @param first The first release
* @param second The second release
* @return True if the same release
* @since 0.0.1
*/
public static boolean isSameRelease(@NotNull String first, @NotNull String second) {
return semVerComparator().compare(first, second) == 0;
}

/**
* Sorts the specified semantic version numbers, from latest to oldest.
* Sorts the specified semantic version numbers, from latest to oldest. The smaller value describes the newer release.
*
* @return The comparator
* @since 0.0.1
Expand Down

0 comments on commit f35ddb2

Please sign in to comment.