mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 05:27:43 -05:00
Fix broken etag handling. Maybe fixes #802
This commit is contained in:
@@ -161,13 +161,6 @@ public class Download {
|
||||
eTag = readEtag(output);
|
||||
}
|
||||
|
||||
try {
|
||||
createParentDirs(output.toFile());
|
||||
Files.deleteIfExists(output);
|
||||
} catch (IOException e) {
|
||||
throw error(e, "Failed to prepare path for download");
|
||||
}
|
||||
|
||||
final HttpRequest httpRequest = eTag
|
||||
.map(this::getETagRequest)
|
||||
.orElseGet(this::getRequest);
|
||||
@@ -186,6 +179,13 @@ public class Download {
|
||||
}
|
||||
|
||||
if (success) {
|
||||
try {
|
||||
createParentDirs(output.toFile());
|
||||
Files.deleteIfExists(output);
|
||||
} catch (IOException e) {
|
||||
throw error(e, "Failed to prepare path for download");
|
||||
}
|
||||
|
||||
final long length = Long.parseLong(response.headers().firstValue("Content-Length").orElse("-1"));
|
||||
AtomicLong totalBytes = new AtomicLong(0);
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ class DownloadFileTest extends DownloadTest {
|
||||
def output = new File(File.createTempDir(), "etag.txt").toPath()
|
||||
|
||||
when:
|
||||
for (i in 0..<2) {
|
||||
for (i in 0..<3) {
|
||||
Download.create("$PATH/etag")
|
||||
.etag(true)
|
||||
.downloadPath(output)
|
||||
|
||||
Reference in New Issue
Block a user