diff options
| author | Pitu <[email protected]> | 2017-10-04 02:45:45 -0300 |
|---|---|---|
| committer | Pitu <[email protected]> | 2017-10-04 02:45:45 -0300 |
| commit | 149742ab6181f7ac7101897c3c1473ceb16ebd9c (patch) | |
| tree | 907fa12ded2d1729f40f461d96334ae82aa6734c /controllers/albumsController.js | |
| parent | Updated README and added nginx sample configuration file (diff) | |
| download | host.fuwn.me-149742ab6181f7ac7101897c3c1473ceb16ebd9c.tar.xz host.fuwn.me-149742ab6181f7ac7101897c3c1473ceb16ebd9c.zip | |
Bypass file if not found when zipping an album
Diffstat (limited to 'controllers/albumsController.js')
| -rw-r--r-- | controllers/albumsController.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/controllers/albumsController.js b/controllers/albumsController.js index c1a36f1..11b7903 100644 --- a/controllers/albumsController.js +++ b/controllers/albumsController.js @@ -152,7 +152,13 @@ albumsController.generateZip = async (req, res, next) => { let archive = new Zip(); for (let file of files) { - archive.file(file.name, fs.readFileSync(path.join(__dirname, '..', config.uploads.folder, file.name))); + 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 |