diff --git a/CHANGES.md b/CHANGES.md index 32126d30..5ae84251 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,7 @@ Changes: Fixes: - Disables notifications in Safari due to API limitations ([391](https://github.com/freelawproject/recap-chrome/pull/391)). - Fix fetch on firefox ([393](https://github.com/freelawproject/recap-chrome/pull/393)). + - Adds logic to clean up storage after uploads. For developers: - Preserves permissions during macOS and iOS release package creation ([391](https://github.com/freelawproject/recap-chrome/pull/391)) diff --git a/src/utils/background_fetch.js b/src/utils/background_fetch.js index f4fe1e3f..67e962d1 100644 --- a/src/utils/background_fetch.js +++ b/src/utils/background_fetch.js @@ -100,6 +100,13 @@ async function triggerFetchRequest(url, options, sender, sendResponse) { const blob = await fetch(file).then((res) => res.blob()); const body = buildFormData({ ...options.body, filepath_local: blob }); await waitUntil(dispatchCallback(url, { ...options, body })); + + // Remove the 'pdf_blob' and 'zip_blob' properties from the specified key + // in Chrome's local storage after uploading their content. + if (store[storeKey]['pdf_blob']) delete store[storeKey]['pdf_blob']; + if (store[storeKey]['zip_blob']) delete store[storeKey]['zip_blob']; + await chrome.storage.local.set({ [storeKey]: store[storeKey] }); + console.info('Temporary file data removed from storage.'); }); // return true to allow for the async function to complete return true;