Topic on Extension talk:MsUpload

Check for duplicate content

4
Jamesmontalvo3 (talkcontribs)

If I drag a file onto the "drop files here", upload it, then I change the name of the file on my computer and drag it again again and upload, I do not get the duplicate file warning I get on the standard Special:Upload page. Would it be possible to enable this check?

Jamesmontalvo3 (talkcontribs)
Jamesmontalvo3 (talkcontribs)

Looking into this a bit more, there are two ways that it would be possible to determine if there are duplicate files on the server.

  1. Compute the sha1 hash in the browser, then use API:Allimages to find images with the same hash
  2. Upload the file with API:Upload with the "stash" property set to "1". This prevents it from uploading it to the file repository and keeps it stashed temporarily. It also returns any error messages, including if there are duplicate files. This is what Extension:UploadWizard does to check for duplicates.

Extension:MsUpload uses the Plupload library to handle uploads. I've attempted to generate a sha1 from files handled by Plupload using CryptoJS, but have not been able to accurately generate the hash. See this issue submitted to Plupload and this issue submitted to CrytoJS.

For uploading the file with `stash=1`, Plupload does not appear to have a method to upload a single file and perform a check. It only has the `start()` method (see methods) which uploads all files in the queue. It may be possible to modify MsUpload's onBeforeUpload method to add stash=1 to multipart_params, then run start(), check for errors, then be able to run start() again without stash=1 for the actual upload (assuming no errors). However, running start() once appears to do something to break Plupload. I have not dug deeply into this aspect.

Jamesmontalvo3 (talkcontribs)
Reply to "Check for duplicate content"