Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -146,17 +146,17 @@ describe('resourcesTransfer', () => {
resourcesToMove,
targetSpace,
resourcesToMove[0],
computed(() => mock<Resource>()),
computed(() => mock<Resource>({ 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
Expand Down