Repository navigation
Conversation
adds scripts/remove-ghost-papers.mjs, run with npm run ghost-papers. it sends a HEAD request to the file_url of every record in papers and admins, the same check the viewer does, and lists the ones that answer 404. anything else (403, 5xx, timeouts, no url) is left alone it is a dry run unless --delete is passed. with --delete it saves the full records to ghost-papers-<time>.json first, then deletes them, and only if their file_url has not changed since the check. it refuses to delete when more than half the files are missing, since a moved or renamed bucket also answers 404 refs CodeChefVIT#545
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.
closes #545
adds scripts/remove-ghost-papers.mjs for removing the records whose pdf no longer exists in the bucket
usage, with MONGODB_URI in .env:
how it decides
safety
tested against an in-memory mongodb and a local file server: the dry run changed nothing, --delete removed exactly the 404 records from both collections and kept the 403/500/unreachable/no-url ones, the backup had the full records, a second run found nothing, and the more-than-half guard refused with all files missing. also checked that storage.googleapis.com answers 404 for a missing object in a public bucket
notes