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:
parent
bafa486668
commit
105d5007cf
1 changed files with 2 additions and 1 deletions
|
@ -330,7 +330,8 @@ app.get('/download-user-file', async (req, res) => {
|
||||||
|
|
||||||
let zip = new AdmZip();
|
let zip = new AdmZip();
|
||||||
try {
|
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) {
|
} catch (e) {
|
||||||
res.status(500).send('Error reading files');
|
res.status(500).send('Error reading files');
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue