fix: zip only necessary files in budget download

While investigating #54 it was noted that the previous implementation
zips the entire budget folder in the download endpoint. Once received on
the client side, only the most recent db and metadata are actually used.
This means up to 10 backups are being zipped in memory and transferred
to the client (in addition to the two necessary files) despite none of
that data being used. While this inefficiency isn't a major concern in
some environments, it may be problematic in memory constrained
environments.

This change transfers only the files that are actually utilized.

issue #54
This commit is contained in:
Arthur E. Jones 2022-08-10 11:47:00 -05:00 committed by James Long
parent bafa486668
commit 105d5007cf

View file

@ -330,7 +330,8 @@ app.get('/download-user-file', async (req, res) => {
let zip = new AdmZip();
try {
zip.addLocalFolder(join(config.userFiles, fileId), '/');
zip.addLocalFile(join(config.userFiles, fileId, 'db.sqlite'), '');
zip.addLocalFile(join(config.userFiles, fileId, 'metadata.json'), '');
} catch (e) {
res.status(500).send('Error reading files');
return;