From c38e378a329d60c7d1e6c2a4706e44a17dd4bdb5 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Fri, 24 Sep 2021 17:15:22 +0200 Subject: [PATCH] fix deleting --- apps/remix-ide/src/app/files/fileProvider.js | 13 ++++++------- .../workspace/src/lib/remix-ui-workspace.tsx | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileProvider.js b/apps/remix-ide/src/app/files/fileProvider.js index 4f4d731baa..3b05ec0e9f 100644 --- a/apps/remix-ide/src/app/files/fileProvider.js +++ b/apps/remix-ide/src/app/files/fileProvider.js @@ -80,7 +80,6 @@ class FileProvider { async _exists (path) { path = this.getPathFromUrl(path) || path // ensure we actually use the normalized path from here var unprefixedpath = this.removePrefix(path) - console.log(this.addSlash(unprefixedpath)) return path === this.type ? true : await window.remixFileSystem.exists(this.addSlash(unprefixedpath)) } @@ -103,8 +102,8 @@ class FileProvider { async set (path, content, cb) { var unprefixedpath = this.removePrefix(path) - const exists = await window.remixFileSystem.exists(unprefixedpath) - if (exists && await window.remixFileSystem.readFile(unprefixedpath, 'utf8') === content) { + const exists = await window.remixFileSystem.exists(this.addSlash(unprefixedpath)) + if (exists && await window.remixFileSystem.readFile(this.addSlash(unprefixedpath), 'utf8') === content) { if (cb) cb() return null } @@ -117,9 +116,9 @@ class FileProvider { return false } if (!exists) { - this.event.emit('fileAdded', this._normalizePath(unprefixedpath), false) + this.event.emit('fileAdded', this._normalizePath(this.addSlash(unprefixedpath)), false) } else { - this.event.emit('fileChanged', this._normalizePath(unprefixedpath)) + this.event.emit('fileChanged', this._normalizePath(this.addSlash(unprefixedpath))) } if (cb) cb() return true @@ -181,13 +180,13 @@ class FileProvider { if (items.length !== 0) { for (const item of items) { const curPath = `${path}${path.endsWith('/') ? '' : '/'}${item}` - if ((await window.remixFileSystem.statExtended(curPath)).isDirectory()) { // delete folder + if ((await window.remixFileSystem.statExtended(this.addSlash(curPath))).isDirectory()) { // delete folder await this.remove(curPath) } else { // delete file await this.removeFile(curPath) } } - if (await window.remixFileSystem.readdir(this.addSlash(path)).length === 0) await window.remixFileSystem.rmdir(path) + await window.remixFileSystem.rmdir(this.addSlash(path)) } else { // folder is empty await window.remixFileSystem.rmdir(this.addSlash(path)) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 49676c2b08..deec7aef05 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -229,7 +229,7 @@ export const Workspace = (props: WorkspaceProps) => { const onFinishDeleteWorkspace = async () => { await props.fileManager.closeAllFiles() const workspacesPath = props.workspace.workspacesPath - props.browser.remove(workspacesPath + '/' + state.currentWorkspace) + await props.browser.remove(workspacesPath + '/' + state.currentWorkspace) const name = state.currentWorkspace setWorkspace(NO_WORKSPACE) props.workspaceDeleted({ name })