|
|
@ -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) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|