fix DownloadUtil not downloading file if ETag present, but file is not
parent
38c395b2e7
commit
3d21ce811b
|
@ -42,6 +42,7 @@ import java.net.URL;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.zip.ZipError;
|
||||
|
||||
public class MinecraftProvider extends DependencyProvider {
|
||||
|
||||
|
@ -89,7 +90,15 @@ public class MinecraftProvider extends DependencyProvider {
|
|||
libraryProvider.provide(this, project);
|
||||
|
||||
if (!MINECRAFT_MERGED_JAR.exists()) {
|
||||
try {
|
||||
mergeJars(project.getLogger());
|
||||
} catch (ZipError e) {
|
||||
DownloadUtil.delete(MINECRAFT_CLIENT_JAR);
|
||||
DownloadUtil.delete(MINECRAFT_SERVER_JAR);
|
||||
|
||||
project.getLogger().error("Could not merge JARs! Deleting source JARs - please re-run the command and move on.", e);
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ public class DownloadUtil {
|
|||
}
|
||||
|
||||
long modifyTime = connection.getHeaderFieldDate("Last-Modified", -1);
|
||||
if (code == HttpURLConnection.HTTP_NOT_MODIFIED || modifyTime > 0 && to.exists() && to.lastModified() >= modifyTime) {
|
||||
if (to.exists() && (code == HttpURLConnection.HTTP_NOT_MODIFIED || modifyTime > 0 && to.lastModified() >= modifyTime)) {
|
||||
if (!quiet) logger.info("'{}' Not Modified, skipping.", to);
|
||||
return; //What we've got is already fine
|
||||
}
|
||||
|
@ -180,4 +180,20 @@ public class DownloadUtil {
|
|||
return String.format("%.2f GB", bytes / (1024.0 * 1024.0 * 1024.0));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the file along with the corresponding ETag, if it exists.
|
||||
*
|
||||
* @param file The file to delete.
|
||||
*/
|
||||
public static void delete(File file) {
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
|
||||
File etagFile = getETagFile(file);
|
||||
if (etagFile.exists()) {
|
||||
etagFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue