fix migration

pull/5370/head
yann300 4 years ago
parent 465d8ce803
commit 7a96674853
  1. 2
      apps/remix-ide/src/app.js
  2. 15
      apps/remix-ide/src/migrateFileSystem.js

@ -485,7 +485,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
// get the file list from the parent iframe // get the file list from the parent iframe
loadFileFromParent(fileManager) loadFileFromParent(fileManager)
migrateToWorkspace(fileManager) migrateToWorkspace(fileManager, filePanel)
if (params.embed) framingService.embed() if (params.embed) framingService.embed()
} }

@ -21,7 +21,7 @@ export default (fileProvider) => {
fileStorageBrowserFS.set(flag, 'done') fileStorageBrowserFS.set(flag, 'done')
} }
export async function migrateToWorkspace (fileManager) { export async function migrateToWorkspace (fileManager, filePanel) {
const browserProvider = fileManager.getProvider('browser') const browserProvider = fileManager.getProvider('browser')
const workspaceProvider = fileManager.getProvider('workspace') const workspaceProvider = fileManager.getProvider('workspace')
const flag = 'status' const flag = 'status'
@ -31,19 +31,20 @@ export async function migrateToWorkspace (fileManager) {
console.log(files) console.log(files)
const workspaceName = 'default_workspace' const workspaceName = 'default_workspace'
const workspacePath = joinPath('browser', workspaceProvider.workspacesPath, workspaceName) const workspacePath = joinPath('browser', workspaceProvider.workspacesPath, workspaceName)
await fileManager.createWorkspace(workspaceName) await filePanel.createWorkspace(workspaceName)
await populateWorkspace(workspacePath, files, fileManager) filePanel.getWorkspaces() // refresh list
await populateWorkspace(workspacePath, files, browserProvider)
fileStorageBrowserWorkspace.set(flag, 'done') fileStorageBrowserWorkspace.set(flag, 'done')
} }
const populateWorkspace = async (workspace, json, fileManager) => { const populateWorkspace = async (workspace, json, browserProvider) => {
for (const item in json) { for (const item in json) {
const isFolder = json[item].content === undefined const isFolder = json[item].content === undefined
if (isFolder) { if (isFolder) {
await fileManager.mkdir(joinPath(workspace, item)) browserProvider.createDir(joinPath(workspace, item))
await populateWorkspace(workspace, json[item].children, fileManager) await populateWorkspace(workspace, json[item].children, browserProvider)
} else { } else {
await fileManager.writeFile(joinPath(workspace, item), json[item].content) await browserProvider.set(joinPath(workspace, item), json[item].content)
} }
} }
} }

Loading…
Cancel
Save