improve file migration

pull/1021/head
yann300 4 years ago
parent d3bb77d11f
commit 68096028d3
  1. 19
      apps/remix-ide/src/migrateFileSystem.js

@ -26,13 +26,24 @@ export async function migrateToWorkspace (fileManager, filePanel) {
const workspaceProvider = fileManager.getProvider('workspace')
const files = await browserProvider.copyFolderToJson('/')
console.log(files)
if (Object.keys(files).length === 0) {
// we don't have any root file, only .workspaces
// don't need to create a workspace
throw new Error('No file to migrate')
}
if (Object.keys(files).length === 1 && files['/.workspaces']) {
// we don't have any root file, only .workspaces
// don't need to create a workspace
throw new Error('No file to migrate')
}
const workspaceName = 'workspace_migrated_' + Date.now()
await filePanel.processCreateWorkspace(workspaceName)
filePanel.getWorkspaces() // refresh list
if (Object.keys(files).length > 0) {
const workspacePath = joinPath('browser', workspaceProvider.workspacesPath, workspaceName)
await populateWorkspace(workspacePath, files, browserProvider)
}
const workspacePath = joinPath('browser', workspaceProvider.workspacesPath, workspaceName)
await populateWorkspace(workspacePath, files, browserProvider)
return workspaceName
}

Loading…
Cancel
Save