Skip to content

Commit

Permalink
feat(background): Adds logic to clean up storage after upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ERosendo committed Sep 12, 2024
1 parent 5cc7cf4 commit 8adc214
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/utils/background_fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8adc214

Please sign in to comment.