While debugging, I noticed that many files in the group had the same filename - Dissertation.pdf, generic things like that. When I checked the server directory that ought to contain these files, I noticed that some were missing altogether. I've narrowed down the cause to the duplicate filenames. There was no proper check in cac-group-library to ensure that a file uploaded to a group didn't overwrite another file with the same filename uploaded to the same group. (This bug was inherited from the buddypress-group-documents plugin, so has been present on the Commons for many years.)
To be more specific, what happened is as follows:
- User uploaded a file to the group with attachment Dissertation.pdf
- User uploaded another file to the group with an attachment Dissertation.pdf - different document, same name
- In some cases, cac-group-library tried to save the new file (overwriting the old one), but because of some inconsistent internal checks, the old file was deleted and the new one was not saved. So neither was present. This explains why clicking on some files led to the homepage - cac-group-library doesn't have a good way to deal with a file download attempt when the source file cannot be found due to an error. (More on this below.)
- In other cases, cac-group-library successfully overwrote the old file, which is why the user reports clicking one one user's file but seeing another.
In https://github.com/cuny-academic-commons/cac-group-library/commit/a4405425d971171cbcfb3c759e53a18efee9084d I've added a uniqueness check. Similar to what happens on your operating system, uploading Dissertation.pdf to a group when a file by the same name exists will result in Dissertation-2.pdf, Dissertation-3.pdf, etc. This change will be live on the server within the next hour, as part of today's scheduled release.
Unfortunately, there's no way for me to recover files that have been uploaded. The user will have to delete/recreate the corrupted items. Please extend apologies to the user, and thanks for their patience.
I will open a separate ticket to address the case where the attached file cannot be found on the server. While this should never happen in theory (and will no longer happen in the case described in this ticket) we should still handle it more gracefully than simply redirecting to the home page.