removed Content-Length from downloadTar API as it would lead to file truncation

This commit is contained in:
2024-02-27 05:12:15 +08:00
parent 5e7f0b179b
commit f48a201406

View File

@@ -307,10 +307,6 @@ public class PacmanWebService {
public Response downloadTar(@FormParam("pkgs") String formData) {
String[] files = URLDecoder.decode(formData, StandardCharsets.UTF_8).split(" ");
Fun<java.nio.file.Path, Long> fun = Files::size;
long estimatedSize = Arrays.stream(files)
.map(ctx::getFile)
.mapToLong(fun::apply)
.sum();
Arrays.stream(files)
.filter(fileName -> !Files.exists(ctx.getFile(fileName)))
.forEach(fileName -> {
@@ -341,7 +337,6 @@ public class PacmanWebService {
}
};
return Response.ok(stream)
.header("Content-Length", estimatedSize)
.header("Content-Disposition", "attachment; filename=pkgs.tar")
.build();
}