mirror of
https://github.com/zen-browser/components.git
synced 2025-07-07 22:29:59 +02:00
feat(workspaces): Migrate workspaces from JSON to the new storage after sync engine has been registered.
This commit is contained in:
parent
775b5288fb
commit
9abd2d9cc1
2 changed files with 3 additions and 4 deletions
|
@ -22,6 +22,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||
if(!Weave.Service.engineManager.get("workspaces")) {
|
||||
Weave.Service.engineManager.register(ZenWorkspacesEngine);
|
||||
}
|
||||
await ZenWorkspacesStorage.migrateWorkspacesFromJSON();
|
||||
await this.initializeWorkspaces();
|
||||
console.info('ZenWorkspaces: ZenWorkspaces initialized');
|
||||
|
||||
|
|
|
@ -29,18 +29,16 @@ var ZenWorkspacesStorage = {
|
|||
)
|
||||
`);
|
||||
});
|
||||
|
||||
await this._migrateWorkspacesFromJSON();
|
||||
},
|
||||
|
||||
async _migrateWorkspacesFromJSON() {
|
||||
async migrateWorkspacesFromJSON() {
|
||||
const oldWorkspacesPath = PathUtils.join(PathUtils.profileDir, 'zen-workspaces', 'Workspaces.json');
|
||||
if (await IOUtils.exists(oldWorkspacesPath)) {
|
||||
console.info('ZenWorkspacesStorage: Migrating workspaces from JSON...');
|
||||
const oldWorkspaces = await IOUtils.readJSON(oldWorkspacesPath);
|
||||
if (oldWorkspaces.workspaces) {
|
||||
for (const workspace of oldWorkspaces.workspaces) {
|
||||
await this.saveWorkspace(workspace, false); // Disable immediate notification
|
||||
await this.saveWorkspace(workspace);
|
||||
}
|
||||
}
|
||||
await IOUtils.remove(oldWorkspacesPath);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue