Fixed Remixd folder delete bug and changed rmdir, unlink to remove api

pull/4/head
ioedeveloper 5 years ago
parent fcec4fef36
commit 4cc3802d29
  1. 22
      src/app/files/file-explorer.js
  2. 27
      src/app/files/fileManager.js
  3. 3
      src/app/files/remixDProvider.js

@ -236,12 +236,14 @@ function fileExplorer (localRegistry, files, menuItems) {
modalDialogCustom.confirm(`Confirm to delete folder`, `Are you sure you want to delete ${currentFoldername} folder?`,
async () => {
const fileManager = self._deps.fileManager
const removeFolder = await fileManager.rmdir(key)
const removeFolder = await fileManager.remove(key)
if (!removeFolder) {
tooltip(`failed to remove ${key}. Make sure the directory is empty before removing it.`)
} else {
self.updatePath('browser')
const { type } = fileManager.currentFileProvider()
self.updatePath(type)
}
}, () => {})
}
@ -278,9 +280,17 @@ function fileExplorer (localRegistry, files, menuItems) {
modalDialogCustom.confirm(
`Delete file`, `Are you sure you want to delete ${currentFilename} file?`,
() => {
files.remove(key)
self.updatePath('browser')
async () => {
const fileManager = self._deps.fileManager
const removeFile = await fileManager.remove(key)
if (!removeFile) {
tooltip(`failed to remove file ${key}.`)
} else {
const { type } = fileManager.currentFileProvider()
self.updatePath(type)
}
},
() => {}
)

@ -23,7 +23,7 @@ const profile = {
icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMTc5MiIgaGVpZ2h0PSIxNzkyIiB2aWV3Qm94PSIwIDAgMTc5MiAxNzkyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0xNjk2IDM4NHE0MCAwIDY4IDI4dDI4IDY4djEyMTZxMCA0MC0yOCA2OHQtNjggMjhoLTk2MHEtNDAgMC02OC0yOHQtMjgtNjh2LTI4OGgtNTQ0cS00MCAwLTY4LTI4dC0yOC02OHYtNjcycTAtNDAgMjAtODh0NDgtNzZsNDA4LTQwOHEyOC0yOCA3Ni00OHQ4OC0yMGg0MTZxNDAgMCA2OCAyOHQyOCA2OHYzMjhxNjgtNDAgMTI4LTQwaDQxNnptLTU0NCAyMTNsLTI5OSAyOTloMjk5di0yOTl6bS02NDAtMzg0bC0yOTkgMjk5aDI5OXYtMjk5em0xOTYgNjQ3bDMxNi0zMTZ2LTQxNmgtMzg0djQxNnEwIDQwLTI4IDY4dC02OCAyOGgtNDE2djY0MGg1MTJ2LTI1NnEwLTQwIDIwLTg4dDQ4LTc2em05NTYgODA0di0xMTUyaC0zODR2NDE2cTAgNDAtMjggNjh0LTY4IDI4aC00MTZ2NjQwaDg5NnoiLz48L3N2Zz4=',
permission: true,
version: packageJson.version,
methods: ['file', 'exists', 'open', 'writeFile', 'readFile', 'copyFile', 'unlink', 'rename', 'readdir', 'rmdir'],
methods: ['file', 'exists', 'open', 'writeFile', 'readFile', 'copyFile', 'rename', 'readdir', 'remove'],
kind: 'file-system'
}
const errorMsg = {
@ -190,20 +190,6 @@ class FileManager extends Plugin {
await this.writeFile(dest, content)
}
/**
* Removes a file
* @param {string} path path of the file to remove
* @note will not work on a directory, use `rmdir` instead
* @returns {void}
*/
async unlink (path) {
await this._handleExists(path, `Cannot remove file ${path}`)
await this._handleIsDir(path, `Cannot remove file ${path}`)
const provider = this.fileProviderOf(path)
provider.removeFile(path)
}
/**
* Change the path of a file/directory
* @param {string} oldPath current path of the file/directory
@ -251,15 +237,12 @@ class FileManager extends Plugin {
}
/**
* Removes a directory recursively
* @param {string} path path of the directory to remove
* @note will not work on a file, use `unlink` instead
* Removes a file or directory recursively
* @param {string} path path of the directory/file to remove
* @returns {void}
*/
async rmdir (path) {
await this._handleExists(path, `Cannot remove directory ${path}`)
await this._handleIsDir(path, `Cannot remove directory ${path}`)
async remove (path) {
await this._handleExists(path, `Cannot remove file or directory ${path}`)
const provider = this.fileProviderOf(path)
return await provider.remove(path)

@ -129,8 +129,7 @@ module.exports = class RemixDProvider {
})
})
await this._remixd.receiveResponse(callId)
return true
return await this._remixd.receiveResponse(callId)
}
rename (oldPath, newPath, isFolder) {

Loading…
Cancel
Save