hedgedoc / hedgedoc

HedgeDoc - Ideas grow better together

Home Page:https://hedgedoc.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

  1. Create a new note
  2. Upload an image
  3. Confirm that the image renders correctly on the note
  4. Open the image in a new tab (the URL should point directly to the image)
  5. Delete the note where the image is referenced
  6. 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

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.