p5.js-web-editor icon indicating copy to clipboard operation
p5.js-web-editor copied to clipboard

Orphaned Assets Fix

Open yugalkaushik opened this issue 6 months ago • 6 comments

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 develop branch.
  • [x] is descriptively named and links to an issue number, i.e. Fixes #123
  • [x] meets the standards outlined in the accessibility guidelines

yugalkaushik avatar May 17 '26 12:05 yugalkaushik

Hi Yugal! Thanks so much for the PR! Apologies for the delay, will take a look this upcoming week.

khanniie avatar May 24 '26 15:05 khanniie

@khanniie Reminder for review 👩🏼‍💻

yugalkaushik avatar Jun 02 '26 18:06 yugalkaushik

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

khanniie avatar Jun 02 '26 23:06 khanniie

@raclim Hi, I have updated the logic to use a better approach, please review the PR.

yugalkaushik avatar Jun 07 '26 08:06 yugalkaushik

hi @yugalkaushik! good work. left some comments.

i noticed two related issues:

  • deleting uploaded assets from an unsaved sketch only removes them client-side (deleteFile in client/modules/IDE/actions/files.js). the corresponding file in s3 remains under pending/, so deleting an asset should also remove the actual object from s3.
  • listObjectsInS3ForUser() in server/controllers/aws.controller.js only lists objects under ${userId}/. since pending uploads are stored under pending/${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).

skyyash avatar Jun 12 '26 15:06 skyyash

@skyash-dev thank you for the review, I'll fix these in coming days.

yugalkaushik avatar Jun 13 '26 16:06 yugalkaushik