Library items change folders when adding subsequent items in new folders
Kent Yuen reports via Zendesk:
Uploading files to the library to different folders. Every time I add a new file to a new folder, the files in the previous folder change. Example: Folders: Johnson, Smith, Peters. If I had application files for Johnson to the Johnson folder, then add application files for Smith to the Smith folder, the files in the Johnson folder switch to Smith.
Submitted from: https://commons.gc.cuny.edu/groups/engl-dyf-prizes/library/#/?page=1&folder=DPAtkin
#1 Updated by Boone Gorges 10 months ago
- Subject changed from group folder problem to Library items change folders when adding subsequent items in new folders
- Status changed from New to Reporter Feedback
I've tried to reproduce this, but so far have been unsuccessful. To clarify:
1. In a group library, click Add New Item
2. Choose 'Upload file'
3. Give the file a name and description, and in the Folder dropdown select 'Add new folder'. Type in a name (Folder1) and submit.
4. I'm led back to the group library and see the new item listed there. I notice that there's a bug in that the new folder appears in the button list, but the folder item count reads 0 instead of 1 (until the page is refreshed). But if I click the folder name, the proper item shows up.
5. I click Add New Item again, and go through steps 2 and 3, but with a new folder name Folder2.
6. I'm led back to the group library again. Clicking through the Folder1 and Folder2 navigation shows me the files in the proper folders.
Marilyn, could you try to reproduce? Maybe I'm doing something wrong?
#3 Updated by Marilyn Weber 10 months ago
With the video, he sent this:
"The 1st file I click on, instead of the file opening it brings me to the main Academic Commons page.
The 2nd file I click on, it opens up a different file (Karlin instead of Campnovo)."
I can reproduce both problems. #1 seems to be wide-spread - I can't get any PDF to open (and I can in other groups). #2 (wrong doc file) I am mystified by.
#4 Updated by Marilyn Weber 10 months ago
It gets wreirder - I can open a PDF in TCHCalado and TCH Ayaz It seems very hit or miss
#7 Updated by Boone Gorges 10 months ago
- Category name set to Group Library
- Status changed from Reporter Feedback to Staged for Production Release
- Assignee set to Boone Gorges
- Target version set to 1.18.8
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.