Discourse won't delete attachment after period hours

AI-generated summary

The discussion revolves around an issue in Discourse version 3.2.0.beta3-dev where attachments are not renamed as expected after being reuploaded. Tee reports that even after removing a file (1.txt) and reuploading it as 2.txt after the grace period, the attachment retains the original name. The user expected the file to be renamed, but the system serves the old filename. Jagster clarifies that the clean orphan uploads grace period setting only removes files after they are no longer linked, and that Discourse likely uses a hashing mechanism to identify files, meaning renaming without reuploading doesn’t update the link. Tee confirms this behavior, noting that the only way to rename a file is to remove it, wait for it to be deleted, and reupload. Jagster agrees with the observation, suggesting the issue stems from Discourse caching based on file content or hash rather than filename.

Version: 3.2.0.beta3-dev in docker self host.
Settings: I set clean orphan uploads grace period hours to 1 hour.

What i want

Rename the attachment after i uploaded.

1.txt and 2.txt is the same file but different file name in below describtions.

Steps

  1. I upload an 1.txt file to a post, saved.
  2. After 5 minutes, i edit the post and remove 1.txt link, saved.
  3. I rename 1.txt to 2.txt.
  4. I reupload 2.txt to the post after 1 hour.
  5. The attachment still name as 1.txt. NOT 2.txt.

But in this situation, clean orphan settings works.

  1. Upload 1.txt
  2. NOT save the post
  3. After 1 hour, i reupload the 2.txt file
  4. The new attachment link will be 2.txt when download.

That situation is different thing than clean orphan uploads.. does, isn’t it?

Perhaps I’m misunderstanding.

As far as I know, the only way to rename the file after uploading is to remove it and wait for Discourse to delete it, and then reupload it.

I followed this guide (edit the posts to remove the attachment links) to remove the file.

Removing means deleting from harddrive, AFAIK.

But I can confirm this behaviour. Discourse serves old file if it is only renamed (I didn’t bother check if it is really that old file or is it just using old filename with link).

I don’t know anything about code or coding, but Discourse uses somekind hashing I reckon. And as long content doesn’t change name it comes from kind of cache. If you really change that attachement Discourse changes linking too.

4 Likes