Skip to content

Deleting an attachment doesn't actually delete the attachment #1573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 of 2 tasks
QazCetelic opened this issue Apr 21, 2025 · 4 comments
Open
1 of 2 tasks

Deleting an attachment doesn't actually delete the attachment #1573

QazCetelic opened this issue Apr 21, 2025 · 4 comments

Comments

@QazCetelic
Copy link

Describe the current behavior

Deleting an attachment doesn't actually delete the attachment, it just removes the reference in the table.

  1. Delete an attachment in the UI
  2. The reference is removed, but the attachment (and it's data) is still in _gristsys_Files

Steps to reproduce

  1. Pick an attachment and check it's identifier
  2. Delete the attachment

Image

  1. Restart application and ensure the cell is empty
  2. Add back the attachment ID in the database
  3. Attachment reappears after restarting application

Describe the expected behavior

Pressing the delete button on an attachment should actually delete it

Where have you encountered this bug?

Instance information (when self-hosting only)

  • Grist instance:

    • Version: desktop-0.3.2
    • Installation mode: grist-desktop
  • Browser name, version and platforms on which you could reproduce the bug: n/a

  • Link to browser console log if relevant: n/a

  • Link to server log if relevant: n/a

@QazCetelic
Copy link
Author

Unused attachments don’t get cleaned out immediately because it’s somewhat of an expensive operation to figure out which are unused. That’s because the same attachment could be referenced from different cells (and even in different attachment columns or different tables). They do get scanned and cleaned out periodically – about once an hour – so Raw Data should reflect the reduced size after a little while.

https://community.getgrist.com/t/delete-attachment-from-trigger-formula/4955/2

@paulfitz
Copy link
Member

Ah, thanks for figuring this out and following up @QazCetelic. A way to force this housekeeping step as part of an API endpoint would be welcome.

@QazCetelic
Copy link
Author

QazCetelic commented Apr 22, 2025

Thanks for the response. I did notice that the test images I uploaded yesterday (and subsequently "deleted) have still not been cleaned out, am I missing something else or could there be an issue?

EDIT 2025-04-22:
I checked, and the JPG image is still there after being replaced with the WEBP image in the document yesterday. The automatic housekeeping seems to be broken.
Image
Attachment in the table:
Image

EDIT 2025-04023:
The cleanup should be triggered here

There also appears to already be an endpoint to force removing unused attachments intended for testing (/api/docs/:docId/attachments/removeUnused) here

I noticed that the "deleted" file is soft deleted in the attachment table, but not in the files table. 🤔

Image

Image

@QazCetelic QazCetelic reopened this Apr 27, 2025
@QazCetelic
Copy link
Author

I just checked, and the files have remained in the Document. I think the cleanup functionality may be broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants