Added an automatic updater for new releases.

opsu! will now check for updates upon launching, and will prompt the user to download and run a newer version, if available.
- The remote version file is just the filled "version" file, currently located in the gh-pages branch.
- The new version is downloaded to the working directory, and launched with ProcessBuilder.

Related changes:
- Added "file" property (containing the download URL) to "version" file.
- Added maven-artifact dependency for version comparisons.
- Added methods in Downloads class to retrieve the constructor parameters.
- Moved method for showing exit confirmation dialogs into UI.
- Moved method for reading from URLs into Utils.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han
2015-03-07 04:17:19 -05:00
parent 9138b70a24
commit 078b765143
15 changed files with 437 additions and 74 deletions

View File

@@ -138,9 +138,19 @@ public class Download {
return;
}
this.localPath = localPath;
this.rename = rename;
this.rename = Utils.cleanFileName(rename, '-');
}
/**
* Returns the remote download URL.
*/
public URL getRemoteURL() { return url; }
/**
* Returns the local path to save the download (after renamed).
*/
public String getLocalPath() { return (rename != null) ? rename : localPath; }
/**
* Sets the download listener.
* @param listener the listener to set
@@ -187,9 +197,8 @@ public class Download {
rbc.close();
fos.close();
if (rename != null) {
String cleanedName = Utils.cleanFileName(rename, '-');
Path source = new File(localPath).toPath();
Files.move(source, source.resolveSibling(cleanedName), StandardCopyOption.REPLACE_EXISTING);
Files.move(source, source.resolveSibling(rename), StandardCopyOption.REPLACE_EXISTING);
}
if (listener != null)
listener.completed();