If a restore by uploading a file fails, the file is not removed from file_managed
Closed this issue · 1 comments
When an "upload" restore fails, the uploaded file entry in file_managed
is never removed. This means that, when trying to restore the file a second time, the site will have a fatal error because of a duplicate entry in the that table. This problem exists in D7 too.
PR #141 ready for review and testing.
I chose a different route: to overwrite temporary files that already existed in the file_managed table. Since these are unique timestamped files, and they are stored in the temporary
folder after uploading with the intent of removing them on cron, this doesn't create any issue of concern. The files are deleted after they expire by cron.
@cellear, to test:
- Do a backup of Public Files as a download
- Restore from download, be sure to choose "Public Files Directory". No problem the first time you restore.
- For the second time, click again "Choose file" and choose the SAME file. Select "Pubic Files Directory" again, and click "Restore Now"
At this point you will get a fatal error (the second time):
EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'temporary://mybackdropsite-2023-12-14t21-39-23.tar_.gz' for key 'uri' in EntityDatabaseStorageController->save() (line 789 of...
Apply the patch and try the above again.