Changed fileExplorer to async/await to fix remixd error

pull/4/head
ioedeveloper 5 years ago
parent 12bc629705
commit fcec4fef36
  1. 15
      src/app/files/file-explorer.js
  2. 8
      src/app/files/fileManager.js
  3. 7
      src/app/files/remixDProvider.js

@ -234,8 +234,11 @@ function fileExplorer (localRegistry, files, menuItems) {
const currentFoldername = extractNameFromKey(key)
modalDialogCustom.confirm(`Confirm to delete folder`, `Are you sure you want to delete ${currentFoldername} folder?`,
() => {
if (!files.remove(key)) {
async () => {
const fileManager = self._deps.fileManager
const removeFolder = await fileManager.rmdir(key)
if (!removeFolder) {
tooltip(`failed to remove ${key}. Make sure the directory is empty before removing it.`)
} else {
self.updatePath('browser')
@ -578,13 +581,15 @@ fileExplorer.prototype.createNewFile = function (parentFolder = 'browser') {
let self = this
modalDialogCustom.prompt('Create new file', 'File Name (e.g Untitled.sol)', 'Untitled.sol', (input) => {
if (!input) input = 'New file'
helper.createNonClashingName(parentFolder + '/' + input, self.files, (error, newName) => {
helper.createNonClashingName(parentFolder + '/' + input, self.files, async (error, newName) => {
if (error) return tooltip('Failed to create file ' + newName + ' ' + error)
const fileManager = self._deps.fileManager
const createFile = await fileManager.writeFile(newName, '')
if (!self.files.set(newName, '')) {
if (!createFile) {
tooltip('Failed to create file ' + newName)
} else {
self._deps.fileManager.open(newName)
await fileManager.open(newName)
if (newName.includes('_test.sol')) {
self.events.trigger('newTestFileCreated', [newName])
}

@ -158,9 +158,9 @@ class FileManager extends Plugin {
async writeFile (path, data) {
if (await this.exists(path)) {
await this._handleIsFile(path, `Cannot write file ${path}`)
this.setFile(path, data)
return await this.setFile(path, data)
} else {
this.setFile(path, data)
return await this.setFile(path, data)
}
}
@ -262,7 +262,7 @@ class FileManager extends Plugin {
const provider = this.fileProviderOf(path)
return provider.remove(path)
return await provider.remove(path)
}
init () {
@ -385,7 +385,7 @@ class FileManager extends Plugin {
`, '', { time: 3000 })
}
}
this._setFileInternal(path, content)
return await this._setFileInternal(path, content)
}
_setFileInternal (path, content) {

@ -118,9 +118,9 @@ module.exports = class RemixDProvider {
return this._readOnlyMode || this._readOnlyFiles[path] === 1
}
remove (path) {
async remove (path) {
var unprefixedpath = this.removePrefix(path)
this._remixd.call('sharedfolder', 'remove', {path: unprefixedpath}, (error, result) => {
const callId = await this._remixd.call('sharedfolder', 'remove', {path: unprefixedpath}, (error, result) => {
if (error) console.log(error)
var path = this.type + '/' + unprefixedpath
delete this.filesContent[path]
@ -128,6 +128,9 @@ module.exports = class RemixDProvider {
this.event.trigger('fileRemoved', [path])
})
})
await this._remixd.receiveResponse(callId)
return true
}
rename (oldPath, newPath, isFolder) {

Loading…
Cancel
Save