Commit 68096028 authored by yann300's avatar yann300

improve file migration

parent d3bb77d1
...@@ -26,13 +26,24 @@ export async function migrateToWorkspace (fileManager, filePanel) { ...@@ -26,13 +26,24 @@ export async function migrateToWorkspace (fileManager, filePanel) {
const workspaceProvider = fileManager.getProvider('workspace') const workspaceProvider = fileManager.getProvider('workspace')
const files = await browserProvider.copyFolderToJson('/') const files = await browserProvider.copyFolderToJson('/')
console.log(files) 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() const workspaceName = 'workspace_migrated_' + Date.now()
await filePanel.processCreateWorkspace(workspaceName) await filePanel.processCreateWorkspace(workspaceName)
filePanel.getWorkspaces() // refresh list filePanel.getWorkspaces() // refresh list
if (Object.keys(files).length > 0) { const workspacePath = joinPath('browser', workspaceProvider.workspacesPath, workspaceName)
const workspacePath = joinPath('browser', workspaceProvider.workspacesPath, workspaceName) await populateWorkspace(workspacePath, files, browserProvider)
await populateWorkspace(workspacePath, files, browserProvider)
}
return workspaceName return workspaceName
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment