mirror of
https://github.com/zoriya/flood.git
synced 2026-06-02 02:56:05 +00:00
Merge pull request #474 from dcousens/pipeout
pipe the download directly
This commit is contained in:
+2
-13
@@ -100,25 +100,14 @@ var client = {
|
||||
res.status(404).json({error: 'File not found.'});
|
||||
}
|
||||
} 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