Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions apps/remix-ide/src/app/files/fileManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ class FileManager extends Plugin {
* @param {string} path path of the directory
* @returns {boolean} true if path is a directory.
*/
isDirectory (path) {
async isDirectory (path) {
const provider = this.fileProviderOf(path)
const result = provider.isDirectory(path)
const result = await provider.isDirectory(path)

return result
}
Expand Down Expand Up @@ -362,7 +362,6 @@ class FileManager extends Plugin {
path = this.limitPluginScope(path)
await this._handleExists(path, `Cannot remove file or directory ${path}`)
const provider = this.fileProviderOf(path)

return await provider.remove(path)
} catch (e) {
throw new Error(e)
Expand Down
3 changes: 1 addition & 2 deletions apps/remix-ide/src/app/files/remixDProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = class RemixDProvider extends FileProvider {
})

this._appManager.on('remixd', 'fileRenamed', (oldPath, newPath) => {
this.event.emit('fileRemoved', oldPath, newPath)
this.event.emit('fileRenamed', oldPath, newPath)
})

this._appManager.on('remixd', 'rootFolderChanged', () => {
Expand Down Expand Up @@ -141,7 +141,6 @@ module.exports = class RemixDProvider extends FileProvider {
this._appManager.call('remixd', 'remove', { path: unprefixedpath })
.then(result => {
const path = unprefixedpath

delete this.filesContent[path]
resolve(true)
this.init()
Expand Down
1 change: 0 additions & 1 deletion apps/remix-ide/src/app/panels/tab-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export class TabProxy extends Plugin {

fileManager.events.on('fileRemoved', (name) => {
const workspace = this.fileManager.currentWorkspace()

workspace ? this.removeTab(workspace + '/' + name) : this.removeTab(this.fileManager.mode + '/' + name)
})

Expand Down
2 changes: 1 addition & 1 deletion libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
try {
await fileManager.remove(p)
} catch (e) {
const isDir = state.fileManager.isDirectory(p)
const isDir = await state.fileManager.isDirectory(p)
toast(`Failed to remove ${isDir ? 'folder' : 'file'} ${p}.`)
}
}
Expand Down
1 change: 0 additions & 1 deletion libs/remix-ui/solidity-compiler/src/lib/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
}
.remixui_container {
margin: 0;
margin-bottom: 2%;
}
.remixui_optimizeContainer {
display: flex;
Expand Down
34 changes: 31 additions & 3 deletions libs/remixd/src/services/remixdClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,34 @@ export class RemixdClient extends PluginClient {

if (!fs.existsSync(path)) return reject(new Error('File not found ' + path))
if (!isRealPath(path)) return
// Saving the content of the item{folder} before removing it
const ls = []
try {
const resolveList = (path) => {
if (!this._isFile(path)) {
const list = utils.resolveDirectory(path, this.currentSharedFolder)
Object.keys(list).forEach(itemPath => {
if (list[itemPath].isDirectory) {
resolveList(`${this.currentSharedFolder}/${itemPath}`)
}
ls.push(itemPath)
})
}
}
resolveList(path)
ls.push(args.path)
} catch (e) {
throw new Error(e)
}
return fs.remove(path, (error: Error) => {
if (error) {
console.log(error)
return reject(new Error('Failed to remove file/directory: ' + error))
}
this.emit('fileRemoved', args.path)
for (const file in ls) {
this.emit('fileRemoved', ls[file])
}

resolve(true)
})
})
Expand All @@ -194,10 +216,17 @@ export class RemixdClient extends PluginClient {
}
}

_isFile (path: string): boolean {
try {
return fs.statSync(path).isFile()
} catch (error) {
throw new Error(error)
}
}

isDirectory (args: SharedFolderArgs): boolean {
try {
const path = utils.absolutePath(args.path, this.currentSharedFolder)

return fs.statSync(path).isDirectory()
} catch (error) {
throw new Error(error)
Expand All @@ -207,7 +236,6 @@ export class RemixdClient extends PluginClient {
isFile (args: SharedFolderArgs): boolean {
try {
const path = utils.absolutePath(args.path, this.currentSharedFolder)

return fs.statSync(path).isFile()
} catch (error) {
throw new Error(error)
Expand Down