Skip to content

Commit

Permalink
Fixes update errors
Browse files Browse the repository at this point in the history
  • Loading branch information
robot-rover committed Sep 1, 2016
1 parent 67a6662 commit 63c58bd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

<dependencies>
<!-- Zip4J: Extract and Compress .zip Files -->
<dependency>
<!--<dependency>
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
<version>1.2.5</version>
</dependency>
</dependency>-->
<!-- Spark: Websocket Server -->
<dependency>
<groupId>com.sparkjava</groupId>
Expand Down
9 changes: 3 additions & 6 deletions src/rr/industries/util/BotActions.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package rr.industries.util;

import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -124,7 +122,6 @@ public static boolean saveLog() {
public static void downloadUpdate(String url, IDiscordClient client) {
LOG.info("Downloading new .jar");
File jarFile = new File("sovietBot-master.jar");
File archive = new File("SovietBot-archive.zip");
File backupFile = new File("sovietBot-backup.jar");
try {
Files.copy(jarFile.toPath(), backupFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
Expand All @@ -133,9 +130,9 @@ public static void downloadUpdate(String url, IDiscordClient client) {
return;
}
try {
FileUtils.copyURLToFile(new URL(url), archive, 10000, 10000);
new ZipFile(archive).extractAll("./");
} catch (IOException | ZipException ex) {
Files.delete(jarFile.toPath());
FileUtils.copyURLToFile(new URL(url), jarFile, 10000, 10000);
} catch (IOException ex) {
LOG.error("Error Downloading Jar", ex);
try {
LOG.warn("Restoring from Backup");
Expand Down

0 comments on commit 63c58bd

Please sign in to comment.