I think it would be a fantastic feature if Drupal would stop users from uploading duplicate files. Uploading duplicates right now produces duplicate_N file, which is a waste of space and, more importantly, a site's very precious bandwidth.

I see two methods which could work:

  1. When uploading, and hitting the "rename to file_N" step, check the MD5 of the two files. If they match, just use the old file.
    or, better...
  2. When uploading, keep a MD5 hash in the files table, and check that hash against all existing files. If it exists, use the previously uploade file.

I like option 2 better because it accounts for files with different names more efficiently, but still returns the same content (which is what you really care about)

The other thing to check with this would be that instead of deleting files when they are removed for a node, you would first check to see if any other nodes are using the file. If not, go ahead, otherwise just leave the file in place.

Since 5 is in maintenance and 6 is feature frozen, I guess this'll end up in 7. Perhaps there's an enterprising way to make this a module or something? Need input from more experience Drupal people on that. :)

Comments

webchick’s picture

Version: 7.x-dev » 8.x-dev
Component: upload.module » file.module

This is a nice idea, but unfortunately we're once again past feature freeze. Bumping to 8.x and moving to File module.

swentel’s picture

Status: Active » Closed (duplicate)

Some more discussion already over at #1077598: Check for duplicate files on upload - so marking this one as duplicate.