Bypass file if not found when zipping an album

This commit is contained in:
Pitu 2017-10-04 02:45:45 -03:00
parent 5ff33ba930
commit 149742ab61
1 changed files with 7 additions and 1 deletions

View File

@ -152,8 +152,14 @@ albumsController.generateZip = async (req, res, next) => {
let archive = new Zip();
for (let file of files) {
fs.stat(path.join(__dirname, '..', config.uploads.folder, file.name), (err, stats) => {
if (err) {
console.log(err);
} else {
archive.file(file.name, fs.readFileSync(path.join(__dirname, '..', config.uploads.folder, file.name)));
}
});
}
archive
.generateNodeStream({ type: 'nodebuffer', streamFiles: true })