Skip to content

Commit

Permalink
Constant cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lycano authored and gravitylow committed Jan 8, 2014
1 parent 71c5a85 commit d14a06d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main/java/net/gravitydevelopment/updater/Updater.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class Updater {
private static final String QUERY = "/servermods/files?projectIds="; // Path to GET
private static final String HOST = "https://api.curseforge.com"; // Slugs will be appended to this to get to the project's RSS feed

private static final String USER_AGENT = "Updater (by Gravity)";
private static final String delimiter = "^v|[\\s_-]v"; // Used for locating version numbers in file names
private static final String[] NO_UPDATE_TAG = { "-DEV", "-PRE", "-SNAPSHOT" }; // If the version number contains one of these, don't update.
private static final int BYTE_SIZE = 1024; // Used for downloading files
Expand Down Expand Up @@ -307,7 +308,7 @@ private void saveFile(File folder, String file, String link) {
final URL url = new URL(link);
final int fileLength = url.openConnection().getContentLength();
in = new BufferedInputStream(url.openStream());
fout = new FileOutputStream(folder.getAbsolutePath() + "/" + file);
fout = new FileOutputStream(folder.getAbsolutePath() + File.separator + file);

final byte[] data = new byte[Updater.BYTE_SIZE];
int count;
Expand All @@ -330,7 +331,7 @@ private void saveFile(File folder, String file, String link) {
}
}
// Check to see if it's a zip file, if it is, unzip it.
final File dFile = new File(folder.getAbsolutePath() + "/" + file);
final File dFile = new File(folder.getAbsolutePath() + File.separator + file);
if (dFile.getName().endsWith(".zip")) {
// Unzip
this.unzip(dFile.getCanonicalPath());
Expand Down Expand Up @@ -385,7 +386,7 @@ private void unzip(String file) {
bis.close();
final String name = destinationFilePath.getName();
if (name.endsWith(".jar") && this.pluginFile(name)) {
destinationFilePath.renameTo(new File(this.plugin.getDataFolder().getParent(), this.updateFolder + "/" + name));
destinationFilePath.renameTo(new File(this.plugin.getDataFolder().getParent(), this.updateFolder + File.separator + name));
}
}
entry = null;
Expand Down Expand Up @@ -413,7 +414,7 @@ private void unzip(String file) {
}
if (!found) {
// Move the new file into the current dir
cFile.renameTo(new File(oFile.getCanonicalFile() + "/" + cFile.getName()));
cFile.renameTo(new File(oFile.getCanonicalFile() + File.separator + cFile.getName()));
} else {
// This file already exists, so we don't need it anymore.
cFile.delete();
Expand Down Expand Up @@ -505,7 +506,7 @@ private boolean read() {
if (this.apiKey != null) {
conn.addRequestProperty("X-API-Key", this.apiKey);
}
conn.addRequestProperty("User-Agent", "Updater (by Gravity)");
conn.addRequestProperty("User-Agent", Updater.USER_AGENT);

conn.setDoOutput(true);

Expand Down

0 comments on commit d14a06d

Please sign in to comment.