Repository navigation
Description
Description
When a folder is duplicated (Content Drive, #37062) or copied (Site Browser) into a place where its name is taken, the new folder gets _copy appended again for every existing copy:
| Already in the parent | New copy is named |
|---|---|
main_folder |
main_folder_copy |
main_folder, main_folder_copy |
main_folder_copy_copy |
main_folder, main_folder_copy, main_folder_copy_copy |
main_folder_copy_copy_copy |
Seen while testing #37062: the second duplicate of main_folder came out as main_folder_copy_copy. The names get long fast, and it's hard to tell how many copies exist or which one is newest.
Where it comes from: the rename loop in FolderFactoryImpl.copy, in both overloads (site destination around line 434, folder destination around line 461):
while (rename) {
newFolder.setName(newFolder.getName() + "_copy");
rename = folderContains(newFolder.getName(), destination);
}Content Drive's duplicate (FolderDuplicator) and the Site Browser copy both go through this code, so one change covers both.
Proposed: keep one _copy and number the following ones: main_folder_copy, then main_folder_copy_1, main_folder_copy_2, …, taking the first free number.
qa-content-drive-number-copy.mov
Acceptance Criteria
- The first copy of
Xis still namedX_copy. - When
X_copyexists, the next copy isX_copy_1, thenX_copy_2, and so on, using the first number not taken in that parent. - Duplicating a copy works the same way (duplicating
X_copygivesX_copy_copy, orX_copy_copy_1if that is taken), so names stay predictable. - The rule applies to both destinations (a folder and a site root) and to both entry points (Content Drive duplicate and Site Browser copy).
- Two duplicates of the same folder submitted at the same time still get two different names (the existing
FolderDuplicatorlock keeps working). - Check name collisions without regard to case. Today
folderContainsanddoesHostContainsFoldercompare with case-sensitiveequals, while theidx_ident_uniq_asset_nameindex compares paths in lowercase. A code review of feat(content-drive): bulk folder duplicate backend (#37062) #37760 flagged that duplicatingAlphanext to an existingalpha_copywould pickAlpha_copyand fail on the index (not reproduced yet). - Unit tests cover the numbering, and a case-only clash.
Priority
Low
Additional Context
- Found during QA of Content Drive: folder copy, async job endpoint and frontend wiring #37062 (backend feat(content-drive): bulk folder duplicate backend (#37062) #37760).
- Related: [DEFECT] Content Drive: Duplicating a folder copies subfolders and files the user cannot read #37893 (a duplicate copies content the user cannot read), [DEFECT] /api/v1/jobs/folderBulkDuplicate skips the 50-folder limit that Content Drive's bulk duplicate enforces #37883 (limit bypass through the generic jobs endpoint).
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsNext Sprint
Activity
[-]Content Drive / Site Browser: number repeat folder copies (name_copy_1) instead of appending _copy again[/-][+]Content Drive: number repeat folder copies (name_copy_1) instead of appending _copy again[/+][-]Content Drive: number repeat folder copies (name_copy_1) instead of appending _copy again[/-][+]Content Drive: number repeat folder copies (`name_copy_1`) instead of appending `_copy` again[/+]