Repository navigation
upload: report orphan images with find_usages and find_orphans - #196
Merged
Merged
Conversation
Usage is computed by scanning bodies and archive tables rather than stored in a join table, because delete_forever overwrites body, body_draft and every archive row with [DELETED] -- references leave the database, so a scan is always correct. find_orphans is inert until the Upload table lands (crud is stubbed); find_usages works today. Add a make upload-report target.
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.
Summary
Adds orphan detection for uploads:
find_usages(sha)andfind_orphans(), plus amake upload-reporttarget.What's in here
services/uploads.py:find_usages(sha)— scansArticle.body/body_draft,Answer.body/body_draft,Comment.body,Submission.description, and the archive tables for the sha. The URL embeds the sha, so aLIKEhit is exact. Works today.find_orphans()— uploads whose sha appears in no body. Inert until the SQL PR lands (crud.uploadis still stubbed, so there are no shas to scan); it comes alive when the table exists.scripts/upload_report.py+make upload-report— list orphans (or usages of a single sha via--sha). Nothing deletes.Why computed, not stored
delete_foreveroverwritesbody,body_draftand every archive row with"[DELETED]", so references leave the database and a scan is always correct — no join table to maintain, no delete hook to forget.Deferred
The
find_usages/find_orphanstest lives in the SQL PR (it needs the realUploadtable). This PR is code-only and lint-clean.