[Draft] Orphaned Assets Fix#4107
Conversation
Release EnvironmentsThis Environment is provided by Release, learn more! 🔧Environment Status : https://app.release.com/public/Processing%20Foundation/env-58239eb320 |
|
hi @raclim! i was reviewing the PRs around this and realized: why are we allowing asset uploads before a project is saved in the first place? it seems like both this and #4085 originate from that behavior. if a project doesn't exist yet, could we simply prompt the user to save/create the project before allowing uploads?
i might be missing an important use case here, but at first glance that feels simpler than introducing a pending-assets workflow in S3 and handling all the edge cases around moving assets between pending and committed states. is there a reason we need to support uploads to unsaved projects? |

Background
This PR addresses issues with orphaned assets accumulating in the AWS s3 Bucket. Currently, one confirmed cause can be reproduced by:
Another potential cause is when project cloning is disrupted, since it appears that assets are uploaded to s3 before the project is successfully cloned.
Changes:
This PR proposes creating a
pendingfolder within the S3 bucket that will hold uploaded user assets until a user saves their project. On project save, the asset should be removed from thependingfolder and be moved to the general bucket. This PR is incomplete, and currently conflicts with other scenarios, such as when a user uploads assets to a saved project.This solution altogether is also just a suggestion, so I'm definitely open to other ideas on this as well!
aws.controller.js: Referencereq.user.idinstead ofreq.body.userId. Adds in thependingfolder when a user uploads an asset.server/utils/pendingAssets.js: Adds a util that handles committing any pending assets to the general bucket on project save, which should copy the asset and delete it from thependingfolder.server/controllers/project.controller.js: Adds thecommitPendingAssetsutil to the project controller and removes the portion checking for stale files. I felt that this wasn't successfully capturingclient/modules/IDE/actions/project.js: When a user attempts to clone a project, it will now delete any added s3 files if the project cloning fails.I have verified that this pull request:
npm run lint)npm run test)npm run typecheck)developbranch.Fixes #123