Commit 4cc3802d authored by ioedeveloper's avatar ioedeveloper

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

parent fcec4fef
...@@ -236,12 +236,14 @@ function fileExplorer (localRegistry, files, menuItems) { ...@@ -236,12 +236,14 @@ function fileExplorer (localRegistry, files, menuItems) {
modalDialogCustom.confirm(`Confirm to delete folder`, `Are you sure you want to delete ${currentFoldername} folder?`, modalDialogCustom.confirm(`Confirm to delete folder`, `Are you sure you want to delete ${currentFoldername} folder?`,
async () => { async () => {
const fileManager = self._deps.fileManager const fileManager = self._deps.fileManager
const removeFolder = await fileManager.rmdir(key) const removeFolder = await fileManager.remove(key)
if (!removeFolder) { if (!removeFolder) {
tooltip(`failed to remove ${key}. Make sure the directory is empty before removing it.`) tooltip(`failed to remove ${key}. Make sure the directory is empty before removing it.`)
} else { } else {
self.updatePath('browser') const { type } = fileManager.currentFileProvider()
self.updatePath(type)
} }
}, () => {}) }, () => {})
} }
...@@ -278,9 +280,17 @@ function fileExplorer (localRegistry, files, menuItems) { ...@@ -278,9 +280,17 @@ function fileExplorer (localRegistry, files, menuItems) {
modalDialogCustom.confirm( modalDialogCustom.confirm(
`Delete file`, `Are you sure you want to delete ${currentFilename} file?`, `Delete file`, `Are you sure you want to delete ${currentFilename} file?`,
() => { async () => {
files.remove(key) const fileManager = self._deps.fileManager
self.updatePath('browser') 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 = { ...@@ -23,7 +23,7 @@ const profile = {
icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMTc5MiIgaGVpZ2h0PSIxNzkyIiB2aWV3Qm94PSIwIDAgMTc5MiAxNzkyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdm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AtMzg0bC0yOTkgMjk5aDI5OXYtMjk5em0xOTYgNjQ3bDMxNi0zMTZ2LTQxNmgtMzg0djQxNnEwIDQwLTI4IDY4dC02OCAyOGgtNDE2djY0MGg1MTJ2LTI1NnEwLTQwIDIwLTg4dDQ4LTc2em05NTYgODA0di0xMTUyaC0zODR2NDE2cTAgNDAtMjggNjh0LTY4IDI4aC00MTZ2NjQwaDg5NnoiLz48L3N2Zz4=',
permission: true, permission: true,
version: packageJson.version, 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' kind: 'file-system'
} }
const errorMsg = { const errorMsg = {
...@@ -191,20 +191,6 @@ class FileManager extends Plugin { ...@@ -191,20 +191,6 @@ class FileManager extends Plugin {
} }
/** /**
* 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 * Change the path of a file/directory
* @param {string} oldPath current path of the file/directory * @param {string} oldPath current path of the file/directory
* @param {string} newPath new path of the file/directory * @param {string} newPath new path of the file/directory
...@@ -251,15 +237,12 @@ class FileManager extends Plugin { ...@@ -251,15 +237,12 @@ class FileManager extends Plugin {
} }
/** /**
* Removes a directory recursively * Removes a file or directory recursively
* @param {string} path path of the directory to remove * @param {string} path path of the directory/file to remove
* @note will not work on a file, use `unlink` instead
* @returns {void} * @returns {void}
*/ */
async rmdir (path) { async remove (path) {
await this._handleExists(path, `Cannot remove directory ${path}`) await this._handleExists(path, `Cannot remove file or directory ${path}`)
await this._handleIsDir(path, `Cannot remove directory ${path}`)
const provider = this.fileProviderOf(path) const provider = this.fileProviderOf(path)
return await provider.remove(path) return await provider.remove(path)
......
...@@ -129,8 +129,7 @@ module.exports = class RemixDProvider { ...@@ -129,8 +129,7 @@ module.exports = class RemixDProvider {
}) })
}) })
await this._remixd.receiveResponse(callId) return await this._remixd.receiveResponse(callId)
return true
} }
rename (oldPath, newPath, isFolder) { rename (oldPath, newPath, isFolder) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment