Add documents with the same filename created issue after deletion of one
See original GitHub issueIssue Summary
We have a content editor who accidentally added the same document twice to the Document Library, and then deleted one. After deleting the one, the file was removed. This led to the following error when the remaining document was attempted to be edited:
An error occurred (404) when calling the HeadObject operation: Not Found
Steps to Reproduce
- Visit ‘/[admin]/documents/multiple/add/’
- Upload a document and change the title to Doc 1
- Upload the same document and change the title to Doc 2
- Delete Doc 2
- Edit Doc 1
Any other relevant information. For example, why do you consider this a bug and what did you expect to happen instead?
Several options:
- When deleting, make sure the file name is not associated with any other Document; if it is, delete the row in the database, and not the file itself.
- Ensure that file names of uploads are unique.
Technical details
- Python version: 3.5.2
- Django version: 1.10.2
- Wagtail version: 1.6.3
- Browser version: Chrome 53
We are using django-storages and boto3 to store our assets on Amazon S3.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Unable to reattach a file with the name that's same as a ...
Solution/Workaround · After you delete the attachment for the list item, click Save. Edit the list item again, reattach the file, and then...
Read more >Can't create file with deleted file name at android 10
I found a solution myself: int fileNo = 0; Uri uri = saveToUri(fileName, contentType, seconds, relativePath); if (uri == null) { while ...
Read more >Same file name in one folder - Dropbox Community
I've moved a folder into a folder with another folder with the exact same name... I didn't realise DB would delete the old...
Read more >Why is space not being freed from disk after deleting a file in ...
The first one listed ([A] instance of the file), has been deleted from the directory hierarchy of the filesystem but because it is...
Read more >Delete and restore files in Google Drive - Android
Files in trash will be automatically deleted after 30 days. You can restore files from ... To remove a file from your Drive,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just to follow up, I’d recommend only doing this for your media files, not static file. Here’s an example
custom_storages.py
I use:Hi @gasman - thanks for the quick response. I’m running wagtail==1.13, django==1.11.6, boto3==1.4.7, botocore==1.7.30.
From the cms
/images/
chooser, JS console prints a pair of 403s for each item with duplicate file names (ending in.max-165x165.png
). Yet the thumbnails are visible. Following link to edit page returns 500:When trying to add a broken image to a page, JS console prints 403 not founds from cloudfrount, and 500s from
/cms/images/chooser/129/select_format/
.