This repository has been archived by the owner on Nov 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added version checking and fixed a server shutdown issue
Added version checking to ensure a user is on the most current version of sync, Fixed issue where closing sync after starting a server would keep the program running. Small changes to documentation.
- Loading branch information
Showing
5 changed files
with
79 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.kirinpatel.util; | ||
|
||
import jdk.nashorn.api.scripting.URLReader; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.util.Scanner; | ||
|
||
public class VersionChecker { | ||
|
||
private final static int VERSION = 1; | ||
private final static int BUILD = 3; | ||
private final static int REVISION = 1; | ||
|
||
public static boolean isUpdated() { | ||
try { | ||
Scanner s = new Scanner(new URLReader(new URL("https://github.com/ajchili/sync/releases"))); | ||
String version = ""; | ||
while (s.hasNext()) { | ||
String line = s.nextLine(); | ||
if (line.contains("tag-reference")) { | ||
s.nextLine(); | ||
version = s.nextLine(); | ||
version = version.substring(version.indexOf("tree/") + 5, version.indexOf("tree/") + 10); | ||
break; | ||
} | ||
} | ||
|
||
for (int i = 0; i < 5; i += 2) { | ||
int parsedInt = Integer.parseInt(version.substring(i, i + 1)); | ||
switch(i) { | ||
case 0: | ||
if (parsedInt != VERSION) return false; | ||
break; | ||
case 2: | ||
if (parsedInt != BUILD) return false; | ||
break; | ||
case 4: | ||
if (parsedInt != REVISION) return false; | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
} catch(MalformedURLException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters