mirror of
https://github.com/zoriya/flood.git
synced 2026-05-31 10:22:44 +00:00
server: pipe the download directly
This commit is contained in:
+2
-12
@@ -101,24 +101,14 @@ var client = {
|
||||
}
|
||||
} else {
|
||||
const tempFilename = `${hash}-${Date.now()}.tar`;
|
||||
const tempFilePath = TemporaryStorage.getTempPath(tempFilename);
|
||||
const archive = archiver('tar', {store: true});
|
||||
const output = fs.createWriteStream(tempFilePath);
|
||||
|
||||
output.on('close', () => {
|
||||
const filename = `${selectedTorrent.name}.tar`;
|
||||
|
||||
res.attachment(path.basename(filename));
|
||||
res.download(tempFilePath, filename, () => {
|
||||
TemporaryStorage.deleteFile(tempFilename);
|
||||
});
|
||||
});
|
||||
|
||||
archive.on('error', (error) => {
|
||||
throw error;
|
||||
});
|
||||
|
||||
archive.pipe(output);
|
||||
res.attachment(`${selectedTorrent.name}.tar`);
|
||||
archive.pipe(res);
|
||||
|
||||
filePathsToDownload.forEach((filePath) => {
|
||||
const filename = path.basename(filePath);
|
||||
|
||||
Reference in New Issue
Block a user