fix deleting

github
bunsenstraat 3 years ago
parent 7639f6828f
commit 648393d924
  1. 13
      apps/remix-ide/src/app/files/fileProvider.js
  2. 2
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx

@ -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))

@ -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 })

Loading…
Cancel
Save