I was pleasantly surprised to find out I can use DemandTools to Dedupe and merge duplicate files (ContentDocument) that my users have uploaded. It works really well when the same person uploads the same file multiple times. However, if 2 different users upload the same file, I'm not able to dedupe and merge those as I get the following error.
Error cloning record 06A6g000007ynorEAA: Invalid sharing type I
The 06A prefix is for the ContendDocumentLink object. So I believe there is an issue happening when it's trying to add both users to the new document it encounters an error, probably because it's copying those records as is and they are both setup as Owners and you can't have 2 owners on 1 file, so.....errror. I'm wondering if there is a way to get around this, or have it only add the user from the winning file?
I would also run a query to see what the 'sharetype' is on some of these ContentDocuments. You'll want to run it off of the ContentDocumentLink object though to see the ShareType. Here's a query you can use:
SELECT Id, LinkedEntityId, ContentDocumentId, IsDeleted, SystemModstamp, ShareType, Visibility FROM ContentDocumentLink WHERE ContentDocumentId = 'INSERT ID HERE'
I think that you'll want the ShareType to be C instead of "I" as this will give the most "open" permissions on the object. Once the permissions are wide open on both files, try to merge them again and see if that helps.
For reference (and to double check my logic 😜)
V Viewer permission. The user can explicitly view but not edit the shared file.
C Collaborator permission. The user can explicitly view and edit the shared file.
I Inferred permission. The user’s permission is determined by the related record. For shares with a library, this is defined by the permissions the user has in that library.