Skip to content

Bound the recursive folder copy: page a folder's contents, then decide on the transaction #37769

Closed as not planned

Description

@zJaaal

Description

Duplicating or copying a folder copies its whole subtree inside one database transaction, and the shipped folder copy reads each folder's file assets, pages and links into memory at once. Both are fine at the sizes most folders are, and neither is fine at the sizes some customers have.

This is existing behaviour, not something #37062 introduced. The Site Browser's copy and every plugin calling FolderAPI.copy go through the same path and have the same limits. It is recorded here as deferred work from #37062 (bulk folder duplicate in Content Drive), which calls bounding this walk "the real work". It is the copy sibling of #37565, which tracks the same for folder delete.

What happens today

  • FolderAPIImpl.copy is @WrapInTransaction: one transaction covers the folder, every subfolder and everything copied into them. A very large subtree holds one connection and one transaction open for the whole copy.
  • FolderFactoryImpl.saveCopiedFolder lists a folder's file assets (findFileAssetsByFolder), working pages (getWorkingHTMLPages) and links in full, with no paging, before copying them. The cost is per folder, not per tree.
  • The Content Drive bulk duplicate runs that copy unchanged, then a second pass that copies what it skips (generic content, archived items) inside the same transaction. That pass reads only identifiers, so it adds little, but it inherits the same transaction.

Why #37062 did not change it

Bounding means either changing the copy for every caller, which is a behaviour change and rollback-unsafe, or adding a second copy path that behaves differently depending on how it was called, permanently. Splitting the copy into several transactions also gives up the all-or-nothing guarantee #37062 relies on: today a failed or cancelled folder leaves no partial duplicate. Copy is milder than delete here: it only reads the originals and inserts new rows, so it does not lock or remove anything other authors are using.

Acceptance Criteria

  • A folder's file assets, pages and links are read in pages rather than all at once.
  • A decision is recorded on the transaction: keep one per top-level folder, or split it. If split, it states what a failed or cancelled copy leaves behind and how the author is told.
  • The Site Browser copy, plugins calling FolderAPI.copy and the Content Drive bulk duplicate keep producing the same result for folders of ordinary size.

Additional Context

Activity

  1. added
    dotCMS : Technical Debt
    on Sep 28, 2026
  2. added theissue type on Sep 28, 2026
  3. zJaaal commented on Oct 9, 2026

    @zJaaal
    MemberAuthor

    Merged into #37565, which now covers both folder delete and folder copy. Both walk the tree the same way (recursive, one transaction for the whole subtree, each folder's contents read in full), so they should be bounded by one shared, paged folder walk rather than fixed twice.

    Everything from this ticket was carried over, including its acceptance criteria and the D-012 / D-013 decision record from specs/37062-folder-copy-backend/spec.md.

    One correction carried along: this ticket said the copy's cost is per folder, not per tree. That is not quite right. FolderFactoryImpl.saveCopiedFolder passes one copiedObjects table through the whole recursion, holding a pair of objects for every file, page and link copied in the tree, so copy memory grows with the whole tree. #37565 now has an acceptance criterion for that.

    Written by Claude (Claude Code) on behalf of @zJaaal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Team : ScoutType : TaskdotCMS : Technical Debt

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions