feat(server): add periodic background cleanup for storage temp staging, upload chunks, and recycle bin (#249, #248) - #253
Open
allenporter wants to merge 7 commits into
Open
allenporter wants to merge 7 commits into
allenporter wants to merge 7 commits into
Conversation
…d chunks, and recycle bin (#249) (#248) - Add StorageCleanupService for periodic pruning of orphaned staging .tmp files and abandoned multipart upload chunks - Add startup sweep for staging temp debris left from server crashes - Add RecycleBinCleanupService for periodic automated recycle bin purging - Fix VFS soft delete recursion for folder hierarchies - Fix VFS recycle purge to delete underlying UserFileDO rows and blob content - Decouple chunk wire parsing into server utils/paths - Remove unused FileService.temp_dir and dead storage_root parameter - Add configuration settings, Prometheus counters, and admin manual trigger endpoints - Enforce strict 1:1 test parity across all modified/new server modules
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #253 +/- ##
==========================================
+ Coverage 90.98% 91.19% +0.21%
==========================================
Files 114 116 +2
Lines 11809 12338 +529
==========================================
+ Hits 10744 11252 +508
- Misses 1065 1086 +21 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Resolves #249 and #248 by introducing scheduled background garbage collection for orphaned storage temp staging files, abandoned multi-part upload chunks, and recycle bin entries, as well as fixing cascading soft-deletes and purge logic.
Problem
.tmpstaging files:LocalBlobStorage.put()stages writes in<storage_root>/temp/<hex>.tmpbefore an atomic rename. Server crashes (SIGKILL, host restarts, OOM) orphaned these staging files permanently.<object_name>.part.<N>in the user data bucket, only deleting them upon final chunk merge. Abandoned/interrupted uploads leave partial chunks behind indefinitely.purge_recycleonly dropped the index row without deleting the underlyingUserFileDOrecords or blob data.FileService.temp_dirand thestorage_rootconstructor parameter were unused.Solution
supernote/server/services/storage_cleanup.py):BlobStorage.cleanup_staging()andBlobStorage.cleanup_chunks()with path traversal protection.max(mtime)of the session to ensure in-flight active uploads are never pruned prematurely.StorageCleanupServiceexecutes an immediate startup sweep (ttl=0) to clear crash debris before starting the periodic background polling loop.supernote/server/services/recycle_cleanup.py):VFS.delete_node()to recursively soft-delete child nodes under folders.VFS.purge_recycle()to delete underlying file records and blob storage content./api/admin/recycle/cleanup.storage_rootparameter and unusedtemp_dirfromFileService.supernote/server/utils/paths.py.Verification
./script/lint: All 9 pre-commit hooks passed cleanly with 0 diagnostics.tests/test_init.py: 1:1 bidirectional structure conformance check passed with an empty allowlist../script/test: 676 tests passed, 54 snapshots passed, 0 failures.