Closed (won't fix)
Project:
File Entity (fieldable files)
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
2 Aug 2011 at 11:03 UTC
Updated:
7 Dec 2015 at 08:00 UTC
Jump to comment: Most recent
Comments
Comment #1
dave reidWe have already made steps towards doing this in 7.x-2.x but you can't do anything if the user uploads the same file twice as they could have the same name but could technically be two different files.
Do you have anything specific where we need to address?
Comment #2
dave reidAlso, why wouldn't you be using the Media Browser at the point that the file has already been uploaded?
Comment #3
comicat commentedMy thoery is : If two files have the same MD5 hash, they must(almostly) be identical in content regardless what file names they got.
Refer to this function:
http://www.php.net/manual/en/function.md5-file.php
which could generate a MD5 hash of a file.
We could use that to avoid file duplication.
Comment #4
aaron commentedthat will work fine until you're looking at a video delivery site where they're working with 8GB files...
Comment #5
Jackinloadup commented@aaron I suppose a remedy to the huge file size issue would be an option to allow fields to be optionally marked as "require unique" content. This seems really valuable to sites with content editors who "dont care" or "dont know better" and just upload the same images over and over. Though I see your point with the video. At the same time it seems that would only be more valuable for a video site. Maybe if the MD5 was done in the background?
I'm not sure what the effect of that would be. From the name I provided it would sound like it will error if the user has already uploaded the file but maybe it should be more like "alias duplicate content"
Then making some kind of way to alias one to another. Possibly with multiple file_managed entries with the "newer" content stating its usage of the original in the file_usage table.
Or maybe when aliasing needs to be done the original fid (A) could be duplicated to create (B) then (A) and the new "file" (C) will be aliased to (B). If any more duplicates show up they will easily be aliased to (B) and you can delete (A), (C) or others with out affecting the each other.
Be warned, I have no idea as to the plausibility of this idea nor do I have the time to dedicate to it. Long live the do-acracy. ^_^
P.S. Thanks for all the hard work you guys do!
Comment #6
comicat commentedOr we maintain a table to dedicatedly store the file entity status, any usage of the file in other table will always reference the file_id/file_md5_hash:
file_id/file_md5_hash(unique) | file_info... | file_status (value may be 'in use[file_id is being reference by other party]' / 'orphan[literally pending to delete]')
Comment #7
l0calh0rst commentedI'd second the need of file uniqueness. Make it optional so the admin can configure what files the uniqueness applies to: mime type, filesize, file extensions etc. The argument with large files is valid but I'd say that the overall majority will not face that problem so why not make them happy?
Upon upload the md5 hash could be calculated and if a file exists just reference the existing file instead of stopping with an error. Clearly the user intended to reference that file to the content so this should be done for him. Optionally an info message could be given.
Comment #8
aaron commentedmoving to file entity
Comment #9
mfer commentedI've got a few thoughts on this...
Comment #10
dave reidYeah this is why people shouldn't be uploading - they should just be referencing the file externally/remotely whether it's a large audio file uploaded to S3, or a picture on Flickr. We can easily prevent duplicates if people don't actually 'upload'. Otherwise we're kinda forced into a bad performance situation if this feature is added.
Comment #11
dave reidAs this could likely be implemented in a separate contrib module since it's not an appropriate "core" feature for File entity, I'm marking this as won't fix.
Comment #12
PatchRanger commentedLooks like there is already a module for that: https://www.drupal.org/project/filehash . According to its README, it is supposed to be used together with https://www.drupal.org/project/fe_paths .