I am not sure if this is a feature of Discourse or it’s a bug, but maybe let’s try to have a discussion about it!
- Discourse setup to use a blob storage for assets
- Upload “image.png” (either using the discourse theme cli or by clicking ‘add’ button under [your_theme]->uploads->add)
- Notice that if you inspect the anchor href of your newly added asset (using dev tools) it’ll be “[your_blob]/user-uploads/original/1X/[hash].png”. This works great.
- Delete [hash].png in the blob storage
- Repest step 2 - re-upload your asset
- Repeat step 3 - notice the url is the same ("[your_blob]/user-uploads/original/1X/[hash].png") and the asset is unable to be found.
I have gotten around this issue with images, I’d change the integrity of it (crop it very slightly, change opacity etc…).
But my main problem is with fonts that have been previously uploaded, I cannot just add spaces to them to get Discourse to re-generate a proper hash for the font. So essentially, because the font existed at one time and is now deleted I can’t seem to use that font again (unless I manage to change the integrity which causes the font to not work because it’s not in the right format).
This makes me curious about a few things:
- Does discourse store asset URLs somewhere? How does it re-generate the same URL for each asset?
- Is the hash determined by hashing the asset (and would therefore always be the same as long as the asset is the same)?
- Is there a better way to delete assets that have been uploaded to a blob? Possibly deleting it from the blob throughs Discourse’s tracking off
I’ve also noticed that when I change the name of the file in my /assets folder, then re-upload my theme (I use the discourse CLI tool) the asset continues to have the same name in [my_theme]->uploads->add.
Anyways, I was hoping someone could help me understand this a little better, cause I think I must be missing something