From 105d5007cf30025266d5b7a188a9ef26374ad97a Mon Sep 17 00:00:00 2001 From: "Arthur E. Jones" Date: Wed, 10 Aug 2022 11:47:00 -0500 Subject: [PATCH] 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 --- app-sync.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app-sync.js b/app-sync.js index bcc8a3c..439f8cc 100644 --- a/app-sync.js +++ b/app-sync.js @@ -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;