Merge branch 'master' into remixd_terminal

pull/1342/head
David Zagi 3 years ago committed by GitHub
commit e03258a185
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      apps/remix-ide/src/app/files/fileManager.js
  2. 3
      apps/remix-ide/src/app/files/remixDProvider.js
  3. 1
      apps/remix-ide/src/app/panels/tab-proxy.js
  4. 2
      libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
  5. 1
      libs/remix-ui/solidity-compiler/src/lib/css/style.css
  6. 34
      libs/remixd/src/services/remixdClient.ts

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

@ -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', () => {
@ -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()

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

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

@ -103,7 +103,6 @@
}
.remixui_container {
margin: 0;
margin-bottom: 2%;
}
.remixui_optimizeContainer {
display: flex;

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

Loading…
Cancel
Save