From b40549de067b7f29354015fa16746cb1ac750caf Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 27 Sep 2023 19:25:34 +0200 Subject: [PATCH 1/3] fix dragging folder into ancestor --- apps/remix-ide/src/app/files/fileManager.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts index 0a80758214..00ecb3b4e0 100644 --- a/apps/remix-ide/src/app/files/fileManager.ts +++ b/apps/remix-ide/src/app/files/fileManager.ts @@ -938,9 +938,16 @@ class FileManager extends Plugin { await this._handleIsDir(src, `Cannot move ${src}. Path is not directory.`) await this._handleIsDir(dest, `Cannot move content into ${dest}. Path is not directory.`) const dirName = helper.extractNameFromKey(src) + const provider = this.fileProviderOf(src) + if (await this.exists(dest + '/' + dirName) || src === dest) { return false } + + if (provider.isSubDirectory(src, dest)) { + this.call('notification', 'toast', recursivePasteToastMsg()) + return false + } return true } catch (e) { console.log(e) @@ -998,7 +1005,13 @@ class FileManager extends Plugin { if (await this.exists(dest + '/' + dirName) || src === dest) { throw createError({ code: 'EEXIST', message: `Cannot move ${src}. Folder already exists at destination ${dest}` }) } - await this.copyDir(src, dest, dirName) + const provider = this.fileProviderOf(src) + + if (provider.isSubDirectory(src, dest)) { + this.call('notification', 'toast', recursivePasteToastMsg()) + return false + } + await this.inDepthCopy(src, dest, dirName) await this.remove(src) } catch (e) { From f0d280997fb439d6475aceab8872ccdaaca73a1c Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 27 Sep 2023 19:26:25 +0200 Subject: [PATCH 2/3] Revert "fix dragging folder into ancestor" This reverts commit b40549de067b7f29354015fa16746cb1ac750caf. --- apps/remix-ide/src/app/files/fileManager.ts | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts index 00ecb3b4e0..0a80758214 100644 --- a/apps/remix-ide/src/app/files/fileManager.ts +++ b/apps/remix-ide/src/app/files/fileManager.ts @@ -938,16 +938,9 @@ class FileManager extends Plugin { await this._handleIsDir(src, `Cannot move ${src}. Path is not directory.`) await this._handleIsDir(dest, `Cannot move content into ${dest}. Path is not directory.`) const dirName = helper.extractNameFromKey(src) - const provider = this.fileProviderOf(src) - if (await this.exists(dest + '/' + dirName) || src === dest) { return false } - - if (provider.isSubDirectory(src, dest)) { - this.call('notification', 'toast', recursivePasteToastMsg()) - return false - } return true } catch (e) { console.log(e) @@ -1005,13 +998,7 @@ class FileManager extends Plugin { if (await this.exists(dest + '/' + dirName) || src === dest) { throw createError({ code: 'EEXIST', message: `Cannot move ${src}. Folder already exists at destination ${dest}` }) } - const provider = this.fileProviderOf(src) - - if (provider.isSubDirectory(src, dest)) { - this.call('notification', 'toast', recursivePasteToastMsg()) - return false - } - await this.inDepthCopy(src, dest, dirName) + await this.copyDir(src, dest, dirName) await this.remove(src) } catch (e) { From 2a9973c5d7be0e5697f456666e2f75e82c3849a0 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 27 Sep 2023 19:27:19 +0200 Subject: [PATCH 3/3] fix dragging into ancestor --- apps/remix-ide/src/app/files/fileManager.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts index 0a80758214..00ecb3b4e0 100644 --- a/apps/remix-ide/src/app/files/fileManager.ts +++ b/apps/remix-ide/src/app/files/fileManager.ts @@ -938,9 +938,16 @@ class FileManager extends Plugin { await this._handleIsDir(src, `Cannot move ${src}. Path is not directory.`) await this._handleIsDir(dest, `Cannot move content into ${dest}. Path is not directory.`) const dirName = helper.extractNameFromKey(src) + const provider = this.fileProviderOf(src) + if (await this.exists(dest + '/' + dirName) || src === dest) { return false } + + if (provider.isSubDirectory(src, dest)) { + this.call('notification', 'toast', recursivePasteToastMsg()) + return false + } return true } catch (e) { console.log(e) @@ -998,7 +1005,13 @@ class FileManager extends Plugin { if (await this.exists(dest + '/' + dirName) || src === dest) { throw createError({ code: 'EEXIST', message: `Cannot move ${src}. Folder already exists at destination ${dest}` }) } - await this.copyDir(src, dest, dirName) + const provider = this.fileProviderOf(src) + + if (provider.isSubDirectory(src, dest)) { + this.call('notification', 'toast', recursivePasteToastMsg()) + return false + } + await this.inDepthCopy(src, dest, dirName) await this.remove(src) } catch (e) {