Skip to content

Content Drive: number repeat folder copies (name_copy_1) instead of appending _copy again #37894

Open

Description

@rjvelazco

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 X is still named X_copy.
  • When X_copy exists, the next copy is X_copy_1, then X_copy_2, and so on, using the first number not taken in that parent.
  • Duplicating a copy works the same way (duplicating X_copy gives X_copy_copy, or X_copy_copy_1 if 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 FolderDuplicator lock keeps working).
  • Check name collisions without regard to case. Today folderContains and doesHostContainsFolder compare with case-sensitive equals, while the idx_ident_uniq_asset_name index compares paths in lowercase. A code review of feat(content-drive): bulk folder duplicate backend (#37062) #37760 flagged that duplicating Alpha next to an existing alpha_copy would pick Alpha_copy and fail on the index (not reproduced yet).
  • Unit tests cover the numbering, and a case-only clash.

Priority

Low

Additional Context

Activity

  1. added theissue type on Oct 5, 2026
  2. changed the title [-]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[/+] on Oct 5, 2026
  3. changed the title [-]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[/+] on Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions