Orphaned Assets Fix
Issue:
Completes #4107
This change adds a pending-upload workflow for user assets so files are not permanently stored until a project is successfully saved. It also adds rollback for failed clones and a scheduled cleanup path for abandoned pending uploads. Uploaded assets now go to a pending S3 prefix first, are committed into the final user/project location on save, and are removed later if they stay pending too long. The cleanup threshold is 7 days.
Demo:
https://github.com/user-attachments/assets/08b4ff78-f764-41bc-ab5c-aa9fcc18520f
Changes:
- Uploads are signed into pending/{userId}/... using the authenticated user id.
- Project creation and project updates both commit any pending assets after a successful save.
- Pending uploads are kept for 7 days before they become eligible for cleanup.
- Abandoned uploads under pending/ are cleaned by an S3 lifecycle rule (prefix pending/, expire after 7 days).
I have verified that this pull request:
- [x] has no linting errors (
npm run lint) - [x] has no test errors (
npm run test) - [x] has no typecheck errors (
npm run typecheck) - [x] is from a uniquely-named feature branch and is up to date with the
developbranch. - [x] is descriptively named and links to an issue number, i.e.
Fixes #123 - [x] meets the standards outlined in the accessibility guidelines
Hi Yugal! Thanks so much for the PR! Apologies for the delay, will take a look this upcoming week.
@khanniie Reminder for review 👩🏼💻
actually if @raclim is back maybe she would be a better reviewer for this one? I don't have much context on the backend side of the editor to be honest
@raclim Hi, I have updated the logic to use a better approach, please review the PR.
hi @yugalkaushik! good work. left some comments.
i noticed two related issues:
- deleting uploaded assets from an unsaved sketch only removes them client-side (
deleteFileinclient/modules/IDE/actions/files.js). the corresponding file in s3 remains underpending/, so deleting an asset should also remove the actual object from s3. listObjectsInS3ForUser()inserver/controllers/aws.controller.jsonly lists objects under${userId}/. since pending uploads are stored underpending/${userId}/, they don't appear in the assets list (#4085).
combining these two issues means there is currently no way for a user to delete uploaded assets from an unsaved sketch (both issues are still present in this release).
@skyash-dev thank you for the review, I'll fix these in coming days.