Repository navigation
Purge generated exports on a configurable retention - #203
Merged
Merged
Conversation
Generated STL/3MF/zip exports are regenerable from stored polygons and bin config, so a background sweep now deletes them once older than STL_RETENTION_HOURS (default 24; 0 keeps them forever). Scope is limited to export suffixes directly inside each user's outputs/ dir; photos, traces, tools, bins, and session data are never touched, and the sweep tolerates files vanishing under it and survives a failing iteration. Delete-on-download was rejected: BinPreview3D streams the same /storage/.../outputs file the download links point at, and /storage is a StaticFiles mount with no per-request hook, so deleting on first fetch would break the preview. The sweep covers both never-downloaded and downloaded leftovers instead. The 24h default never breaks a same-day open page: the frontend re-posts /generate on page load, and a cache hit now refreshes artefact mtimes so files a live page references keep their retention clock running. A stale bin page whose exports were purged no longer opens a dead JSON tab: the export buttons fetch the file, regenerate from saved state on a 404, retry once, and deliver via a blob anchor click. All export endpoints now distinguish expiry (record shows a prior generation) from never generated in their 404 detail, and Content-Disposition is CORS-exposed so blob downloads keep server filenames in dev. Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
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 pendin
2E7B
g 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.
Summary
{storage}/*/outputs/older thanSTL_RETENTION_HOURS(default 24;0keeps everything for self-hosters who want that).Test evidence
backend/venv/bin/python -m pytest370 passed (356 baseline + 14 new)pnpm test151 passed / 18 files (145 baseline + 6 new)make lintexit 0, 0 errors, 9 pre-existing warnings in untouched filesnpx tsc --noEmitcleanRetention loop is tested for exception survival (a raising sweep is logged and the loop continues). Scope tests include decoy files at storage root, wrong suffixes, nested dirs and sibling stores, all asserted to survive. The 404-then-regenerate download path is unit-tested including the no-regenerate-on-500 and throw-on-double-404 branches.
Closes #176