WIP: fix attachment cleanup after media domain migration #818
No reviewers
Labels
No labels
approved, awaiting change
broken setup
bug
cannot reproduce
configuration
documentation
duplicate
enhancement
extremely low priority
feature request
Fix it yourself
help wanted
invalid
mastodon_api
needs change/feedback
needs docs
needs tests
not a bug
not our bug
planned
pleroma_api
privacy
question
static_fe
triage
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
AkkomaGang/akkoma!818
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "Oneric/akkoma:attachcleanup-uploadmigration"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally brought up as apart of #789 and depends on this PR
The current patch requires admins to keep a list of all past domains; this isn’t the most elegant solution, but if properly set works reliably and also reduces points of concern for a future™ migration of the whole upload db scheme (see #765; after which this fix becomes obsolete anyway)
(We could also add a mix task to verify all uploads match a listed base url)
An alternative not requiring so much admin action was suggested by FloatingGhost:
This is probably fine for attachment cleanup, but missed mappings will be more severe for the aforementioned migration. Ofc, we could also just delay worrying about the migration until it actually happens (i’d prefer not to though)
Unless there’s a solution working both reliably and not needing so much manual admin action, this is pretty much a subjective weighting between different drawbacks, so i’ll just adapt the patch to match whatever the final decision yields
I'd imagine one way to try to avoid the problem going forward is to record the domains used for each attachment in the database itself somehow. Won't solve past instances of course, but should help going forward.
Actually looking at this again, even the curent version doesn't deal with domain changes fully correct. It will now kick off a deletion process even for old upload domain versions, but when checking if the attachment is still used by something else the respective URLs are compared without taking a potential base url difference into account. Meaning if file A was first uploaded and used under
oldmedia.example.organd later again but now withimg.example.org, if either post is deleted the uploaded file will be deleted too.This should be fixable without too much hassle using
trim_first_leadingearlier already.If fixed up similar to the above, i guess this would work about the same for deletions as the old-base-url list. The advantage being not having to test all old base urls, the disadvantages being not handling already existing uploads and not assisting with the intended future™ db schema migration.
In the future schema as it is planned now, only relative URLs (and possibly the uploader type) will be recorded in the DB, which makes things much easier to handle. For this to be possible though, we need to identify and strip the base url of all, even old, uploads during the migration.
I’m also not sure if it is worth it to tweak the upload db schema now, if a larger change is planned anyway which will add further complexity to the migration.
So I think if the fix involves a d migration, it should be something which already prepares and helps with the future schema change. If config changes like the one I proposed are also not acceptable, this only leaves some form of best-effort guess and the question is how to do that and the heuristic we arrive at should be good enough to also use during the schema migration in the future.
219fffa0c39a57ab6459View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.