Garbage collection for unreferenced attachments
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 738
- Forks
- 162
- Avg merge
- 6h 2m
- Merged PRs (30d)
- 35
Description
Follow up to #1623 and #1633.
Since #1633, API attachments live in a note's own .attachments. folder. The whole folder is removed when the note is deleted, and a single file can be removed through the new DELETE attachment endpoint. What is still missing is cleanup of attachments that are no longer referenced in a note's text.
When a user edits a note and removes an image or a link, the underlying file stays in .attachments. indefinitely, so orphaned files build up that nobody can reach from the note.
This was left out because finding unused attachments means parsing each note's Markdown to collect the referenced paths, which is the server side parsing we have tried to avoid for sync performance. So it needs a deliberate approach.
Options to consider:
- On note save, parse the referenced paths and delete any file in that note's .attachments. folder that is no longer referenced.
- A separate background or on demand job that does the same sweep across all notes.
Leave deletion to clients through the DELETE endpoint and keep nothing automatic.
Open questions: which trigger is acceptable given the sync performance concern, and how to treat attachments referenced by relative paths that point outside the note's own folder.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the context in issues #1623 and #1633 and the existing DELETE attachment endpoint. The issue presents several possible cleanup triggers but does not choose one; first determine an acceptable approach for parsing note Markdown without harming sync performance and define handling for relative paths outside the note folder. Done means an agreed, implemented cleanup strategy with its edge cases addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, markdown
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100