Uploaded files from deleted notes are not deleted
unode opened this issue · comments
Description
Uploaded files accumulate over time in the upload directory.
Users have no way to delete an uploaded file (related to #2908)
From a sysadmin point of view, there doesn't seem to be any easy way to cleanup the upload folder either nor to identify if files are still being used and/or are referenced in notes.
Steps to reproduce
- Create a new note
- Upload an image
- Confirm that the image renders correctly on the note
- Open the image in a new tab (the URL should point directly to the image)
- Delete the note where the image is referenced
- Refresh the image in the open tab to confirm that the image remains
Expected behaviour
In step 5 the image should no longer be visible.
The same should happen if the link is removed/deleted from the note and no further references to the file exist elsewhere.
Logs
No response
Config
No response
Your Setup
- Host OS: Kubernetes based on https://ghcr.io/linuxserver/hedgedoc-1.9.9
- HedgeDoc version: (Click "Releases" in the footer)
Additional context
After inspecting the database, it doesn't seem like uploads are tracked in any way.
I find only references to them under note content, so at this point I'm not sure if this issue should instead be a feature request. Leaving that call to the project maintainers.
After inspecting the database, it doesn't seem like uploads are tracked in any way.
That's unfortunately right. HedgeDoc 1 does not keep track of that and thus makes removing uploads hard. One could theoretically write a script that searches through the database and matches that with the stored uploads. But such a feature won't be included in HedgeDoc 1.x anymore.
For the work-in-progress HedgeDoc 2.0, uploads are tracked, can be deleted and will be deleted on note deletion.