removed Content-Length from downloadTar API as it would lead to file truncation
This commit is contained in:
@@ -307,10 +307,6 @@ public class PacmanWebService {
|
|||||||
public Response downloadTar(@FormParam("pkgs") String formData) {
|
public Response downloadTar(@FormParam("pkgs") String formData) {
|
||||||
String[] files = URLDecoder.decode(formData, StandardCharsets.UTF_8).split(" ");
|
String[] files = URLDecoder.decode(formData, StandardCharsets.UTF_8).split(" ");
|
||||||
Fun<java.nio.file.Path, Long> fun = Files::size;
|
Fun<java.nio.file.Path, Long> fun = Files::size;
|
||||||
long estimatedSize = Arrays.stream(files)
|
|
||||||
.map(ctx::getFile)
|
|
||||||
.mapToLong(fun::apply)
|
|
||||||
.sum();
|
|
||||||
Arrays.stream(files)
|
Arrays.stream(files)
|
||||||
.filter(fileName -> !Files.exists(ctx.getFile(fileName)))
|
.filter(fileName -> !Files.exists(ctx.getFile(fileName)))
|
||||||
.forEach(fileName -> {
|
.forEach(fileName -> {
|
||||||
@@ -341,7 +337,6 @@ public class PacmanWebService {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
return Response.ok(stream)
|
return Response.ok(stream)
|
||||||
.header("Content-Length", estimatedSize)
|
|
||||||
.header("Content-Disposition", "attachment; filename=pkgs.tar")
|
.header("Content-Disposition", "attachment; filename=pkgs.tar")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user