Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore: Remove files from cache when their upload finished #358

Merged

Conversation

goto-bus-stop
Copy link
Contributor

Another part of #324. This does two things:

  • Omit completed uploads from saved file state—previously, when an upload was finished and the user refreshed the page, all the finished files would still be there because we saved the entire list of files. The first commit changes it to only store files that are part of an in-progress upload, or that have yet to be uploaded.
  • Remove files from cache when upload finished—this uses the deleteBlobs function when core:success fires.

The first is necessary for the second, because otherwise we'd be deleting blobs but keep the data about those files in localStorage still.

The final part of #324 would be to add a timestamp to cached blobs, and to delete old blobs on boot. That code would not have to check the uppy instance ID, but could instead delete old blobs from all instance IDs.

This makes sure that if an upload has finished, and the user refreshes
the page, the old files won't be sitting there in the completed state.

Files that have finished uploading but were part of a "batch" of files
that hasn't finished uploading are also kept.
@arturi
Copy link
Contributor

arturi commented Sep 21, 2017

Great work! Thank you :) This makes me very happy 🏕 Checking the code now.

The final part of #324 would be to add a timestamp to cached blobs, and to delete old blobs on boot. That code would not have to check the uppy instance ID, but could instead delete old blobs from all instance IDs.

Yeah, we could just add added timestamp right in the addFile method?

@arturi
Copy link
Contributor

arturi commented Sep 21, 2017

👍 Good to merge, I think!

@goto-bus-stop
Copy link
Contributor Author

Yeah, we could just add added timestamp right in the addFile method?

Probably--i was thinking of tagging the blobs in indexeddb, so we could easily delete all outdated blobs for all instances in a single query (delete() with a key range for everything below Date.now() - 1 day or so). That way they'd still exist in localStorage state though.

Maybe we should tag both indexedDB and localStorage. I think we should definitely use the indexeddb way because otherwise, if localStorage is cleared while blobs are still in indexedDB, they could stay cached forever. The other way around is less bad because localStorage is only a few kb at most.

@goto-bus-stop goto-bus-stop merged commit 671ab0b into transloadit:master Sep 22, 2017
@kvz
Copy link
Member

kvz commented Sep 25, 2017

/cc @sunil-shrestha

@arturi arturi deleted the feature/rm-blobs-on-complete branch September 25, 2017 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants