404'd images are marked as "errored" #13

This commit is contained in:
4pr0n 2014-04-07 22:37:21 -07:00
parent a5e3acc386
commit 7f390962b6
4 changed files with 15 additions and 5 deletions

View File

@ -4,7 +4,7 @@
<groupId>com.rarchives.ripme</groupId> <groupId>com.rarchives.ripme</groupId>
<artifactId>ripme</artifactId> <artifactId>ripme</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.0.10</version> <version>1.0.11</version>
<name>ripme</name> <name>ripme</name>
<url>http://rip.rarchives.com</url> <url>http://rip.rarchives.com</url>
<properties> <properties>

View File

@ -69,7 +69,19 @@ public class DownloadFileThread extends Thread {
.timeout(TIMEOUT) .timeout(TIMEOUT)
.maxBodySize(MAX_BODY_SIZE) .maxBodySize(MAX_BODY_SIZE)
.execute(); .execute();
FileOutputStream out = (new FileOutputStream(saveAs)); if (response.statusCode() != 200) {
logger.error("[!] Non-OK status code " + response.statusCode() + " while downloading from " + url);
observer.downloadErrored(url, "Non-OK status code " + response.statusCode() + " while downloading " + url.toExternalForm());
return;
}
byte[] bytes = response.bodyAsBytes();
if (bytes.length == 503 && url.getHost().endsWith("imgur.com")) {
// Imgur image with 503 bytes is "404"
logger.error("[!] Imgur image is 404 (503 bytes long): " + url);
observer.downloadErrored(url, "Imgur image is 404: " + url.toExternalForm());
return;
}
FileOutputStream out = new FileOutputStream(saveAs);
out.write(response.bodyAsBytes()); out.write(response.bodyAsBytes());
out.close(); out.close();
break; // Download successful: break out of infinite loop break; // Download successful: break out of infinite loop

View File

@ -17,7 +17,7 @@ import org.jsoup.nodes.Document;
public class UpdateUtils { public class UpdateUtils {
private static final Logger logger = Logger.getLogger(UpdateUtils.class); private static final Logger logger = Logger.getLogger(UpdateUtils.class);
private static final String DEFAULT_VERSION = "1.0.10"; private static final String DEFAULT_VERSION = "1.0.11";
private static final String updateJsonURL = "http://rarchives.com/ripme.json"; private static final String updateJsonURL = "http://rarchives.com/ripme.json";
private static final String updateJarURL = "http://rarchives.com/ripme.jar"; private static final String updateJarURL = "http://rarchives.com/ripme.jar";
private static final String mainFileName = "ripme.jar"; private static final String mainFileName = "ripme.jar";

View File

@ -12,7 +12,6 @@ import java.util.jar.JarFile;
import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
@ -34,7 +33,6 @@ public class Utils {
configPath = configFile; configPath = configFile;
} }
config = new PropertiesConfiguration(configPath); config = new PropertiesConfiguration(configPath);
config.setReloadingStrategy(new FileChangedReloadingStrategy());
logger.info("Loaded " + config.getPath()); logger.info("Loaded " + config.getPath());
} catch (Exception e) { } catch (Exception e) {
logger.error("[!] Failed to load properties file from " + configFile, e); logger.error("[!] Failed to load properties file from " + configFile, e);