From 15679dfe411d2d5b31d3770d36af7ee4fef36303 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Mon, 17 Nov 2025 13:58:08 +0100 Subject: [PATCH] fix: move folder replace Fixes the "Replace" option of the conflict dialog when moving one folder into another. (cherry picked from commit e068345feead0c8929734219d6e86da69ed4378b) --- .../src/helpers/resource/conflictHandling/transfer.ts | 9 ++++++++- .../resource/conflictHandling/resourcesTransfer.spec.ts | 8 ++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/web-pkg/src/helpers/resource/conflictHandling/transfer.ts b/packages/web-pkg/src/helpers/resource/conflictHandling/transfer.ts index 8aff96d153..b827d7c8f3 100644 --- a/packages/web-pkg/src/helpers/resource/conflictHandling/transfer.ts +++ b/packages/web-pkg/src/helpers/resource/conflictHandling/transfer.ts @@ -196,12 +196,19 @@ export class ResourceTransfer extends ConflictDialog { return false } - if (targetFolder.path === unref(this.currentFolder)?.path) { + const currentFolderPath = unref(this.currentFolder)?.path + if (!currentFolderPath || targetFolder.path === currentFolderPath) { return false } const folderName = basename(resource.path) const newPath = join(targetFolder.path, folderName) + + if (currentFolderPath.split('/').length < newPath.split('/').length) { + // this edge case is only possible when moving folders upwards in the hierarchy + return false + } + return targetFolderResources.some((resource) => resource.path === newPath) } } diff --git a/packages/web-pkg/tests/unit/helpers/resource/conflictHandling/resourcesTransfer.spec.ts b/packages/web-pkg/tests/unit/helpers/resource/conflictHandling/resourcesTransfer.spec.ts index 7b97d740e3..8cb8be8bee 100644 --- a/packages/web-pkg/tests/unit/helpers/resource/conflictHandling/resourcesTransfer.spec.ts +++ b/packages/web-pkg/tests/unit/helpers/resource/conflictHandling/resourcesTransfer.spec.ts @@ -132,7 +132,7 @@ describe('resourcesTransfer', () => { expect(resourcesTransfer.resolveFileExists).toHaveBeenCalled() }) - it('should show error message if trying to overwrite parent', async () => { + it('should show error message if trying to overwrite parent', () => { const targetFolderItems = [ { id: 'a', @@ -146,17 +146,17 @@ describe('resourcesTransfer', () => { resourcesToMove, targetSpace, resourcesToMove[0], - computed(() => mock()), + computed(() => mock({ path: '/' })), clientServiceMock, vi.fn(), vi.fn() ) - const namingClash = await resourcesTransfer.isOverwritingParentFolder( + const namingClash = resourcesTransfer.isOverwritingParentFolder( resourcesToMove[0], targetFolder, targetFolderItems ) - const noNamingClash = await resourcesTransfer.isOverwritingParentFolder( + const noNamingClash = resourcesTransfer.isOverwritingParentFolder( resourcesToMove[1], targetFolder, targetFolderItems