Closed (fixed)
Project:
File Hash
Version:
2.x-dev
Component:
Code
Priority:
Major
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
31 Oct 2017 at 15:47 UTC
Updated:
10 Mar 2022 at 13:18 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
o'briatSomething like altering the query in filehash_validate_dedupe() that way :
Comment #3
mfbSounds sensible to me. Adding needs test tag (it also needs a patch of course :)
Comment #4
mfbThe one kinda big problem with this is that it allows duplicate files to be uploaded at the same time (either by the same user, or different users), if they're both temporary files.
Comment #5
mfbIdeally we could fix this upstream in Drupal core - temporary and deleted could be different file statuses?
Comment #6
timwoodWe encounter this issue weekly, sometimes daily, with our users. Sometime they upload a file and then don't finish the process of saving the object the file is attached to (usually a media entity but in some cases filefield on node). Then they try again and get the duplicate file error.
We recently added the https://www.drupal.org/project/media_entity_file_replace module to allow replacing/updating a file while optionally maintaining the original filename, but when there is a validation error (some other required field not filled in or whatever) this module doesn't "carry along" the temporarily uploaded new file and thus the user is stuck with another duplicate file error.
To this point, I think it would be a pretty rare occurrence for this to happen and if it was by the same user on the same edit form, at least only one file would be marked as permanent and the duplicate temp file would be removed eventually anyway.
Comment #7
mfbThis feels more like a feature request / enhancement than bug report - it's working as designed but UX is quite poor :)
Comment #8
foodslover commentedUsing https://www.drupal.org/project/filehash/issues/2920042#comment-12919090 to create a patch to exclude temporary files from duplicate-file-prevention
Comment #9
foodslover commentedComment #10
foodslover commentedComment #11
foodslover commentedComment #12
avpadernoComment #13
mfbPatch doesn't apply, and needs tests
Comment #14
timwoodHere's a patch that should apply cleanly. No tests added so keeping status as Needs work.
Comment #15
avpadernoComment #16
mfbStill needs tests (and there is a minor code style issue to fix up)
Comment #17
timwoodCode style issue fixed, I believe.
Comment #18
mfbI have work underway on this in the 2.x branch (still needs test coverage)
Comment #19
mfbFunctional test for this feature
Comment #21
mfbComment #23
WiseMike commentedPatch #17 worked in my case. Thanks