From 9fb30ce775e8c5ff196ed34a87f67919d65fe039 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Wed, 12 May 2021 07:29:09 +0100 Subject: [PATCH] Wait for exists asynchronous check. --- apps/remix-ide/src/app/panels/file-panel.js | 7 +++++-- libs/remix-ui/file-explorer/src/lib/actions/fileSystem.ts | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide/src/app/panels/file-panel.js b/apps/remix-ide/src/app/panels/file-panel.js index 5628425b34..8e1c656fad 100644 --- a/apps/remix-ide/src/app/panels/file-panel.js +++ b/apps/remix-ide/src/app/panels/file-panel.js @@ -188,8 +188,11 @@ module.exports = class Filepanel extends ViewPlugin { const browserProvider = this._deps.fileProviders.browser const workspacePath = 'browser/' + workspaceProvider.workspacesPath + '/' + name const workspaceRootPath = 'browser/' + workspaceProvider.workspacesPath - if (!browserProvider.exists(workspaceRootPath)) browserProvider.createDir(workspaceRootPath) - if (!browserProvider.exists(workspacePath)) browserProvider.createDir(workspacePath) + const workspaceRootPathExists = await browserProvider.exists(workspaceRootPath) + const workspacePathExists = await browserProvider.exists(workspacePath) + + if (!workspaceRootPathExists) browserProvider.createDir(workspaceRootPath) + if (!workspacePathExists) browserProvider.createDir(workspacePath) } async workspaceExists (name) { diff --git a/libs/remix-ui/file-explorer/src/lib/actions/fileSystem.ts b/libs/remix-ui/file-explorer/src/lib/actions/fileSystem.ts index c9b00bb099..09443366b5 100644 --- a/libs/remix-ui/file-explorer/src/lib/actions/fileSystem.ts +++ b/libs/remix-ui/file-explorer/src/lib/actions/fileSystem.ts @@ -182,7 +182,8 @@ export const fileRenamedSuccess = (path: string, removePath: string, files) => { export const init = (provider, workspaceName: string, plugin, registry) => (dispatch: React.Dispatch) => { if (provider) { provider.event.register('fileAdded', async (filePath) => { - const path = extractParentFromKey(filePath) ? extractParentFromKey(filePath) === '/.workspaces' ? workspaceName : extractParentFromKey(filePath) : workspaceName + if (extractParentFromKey(filePath) === '/.workspaces') return + const path = extractParentFromKey(filePath) || workspaceName const data = await fetchDirectoryContent(provider, path) dispatch(fileAddedSuccess(path, data)) @@ -191,7 +192,8 @@ export const init = (provider, workspaceName: string, plugin, registry) => (disp } }) provider.event.register('folderAdded', async (folderPath) => { - const path = extractParentFromKey(folderPath) ? extractParentFromKey(folderPath) === '/.workspaces' ? workspaceName : extractParentFromKey(folderPath) : workspaceName + if (extractParentFromKey(folderPath) === '/.workspaces') return + const path = extractParentFromKey(folderPath) || workspaceName const data = await fetchDirectoryContent(provider, path) dispatch(folderAddedSuccess(path, data))