Skip to content

Commit

Permalink
backups - 💄 (#160478)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Sep 9, 2022
1 parent 746fda3 commit f54c237
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/vs/code/node/cliProcessMain.ts
Expand Up @@ -116,7 +116,10 @@ class CliMain extends Disposable {
services.set(INativeEnvironmentService, environmentService);

// Init folders
await Promise.all([environmentService.appSettingsHome.fsPath, environmentService.extensionsPath].map(path => path ? Promises.mkdir(path, { recursive: true }) : undefined));
await Promise.all([
environmentService.appSettingsHome.fsPath,
environmentService.extensionsPath
].map(path => path ? Promises.mkdir(path, { recursive: true }) : undefined));

// Log
const logLevel = getLogLevel(environmentService);
Expand Down
16 changes: 10 additions & 6 deletions src/vs/platform/backup/electron-main/backupMainService.ts
Expand Up @@ -74,13 +74,17 @@ export class BackupMainService implements IBackupMainService {
const legacyBackupWorkspacesPath = join(this.backupHome, 'workspaces.json');
const legacyBackupWorkspaces = await Promises.readFile(legacyBackupWorkspacesPath, 'utf8');

await Promises.unlink(legacyBackupWorkspacesPath);
try {
await Promises.unlink(legacyBackupWorkspacesPath);
} catch (error) {
// ignore
}

const legacySserializedBackupWorkspaces = JSON.parse(legacyBackupWorkspaces) as ILegacySerializedBackupWorkspaces;
const legacySerializedBackupWorkspaces = JSON.parse(legacyBackupWorkspaces) as ILegacySerializedBackupWorkspaces;
serializedBackupWorkspaces = {
workspaces: Array.isArray(legacySserializedBackupWorkspaces.rootURIWorkspaces) ? legacySserializedBackupWorkspaces.rootURIWorkspaces : [],
folders: Array.isArray(legacySserializedBackupWorkspaces.folderWorkspaceInfos) ? legacySserializedBackupWorkspaces.folderWorkspaceInfos : [],
emptyWindows: Array.isArray(legacySserializedBackupWorkspaces.emptyWorkspaceInfos) ? legacySserializedBackupWorkspaces.emptyWorkspaceInfos : [],
workspaces: Array.isArray(legacySerializedBackupWorkspaces.rootURIWorkspaces) ? legacySerializedBackupWorkspaces.rootURIWorkspaces : [],
folders: Array.isArray(legacySerializedBackupWorkspaces.folderWorkspaceInfos) ? legacySerializedBackupWorkspaces.folderWorkspaceInfos : [],
emptyWindows: Array.isArray(legacySerializedBackupWorkspaces.emptyWorkspaceInfos) ? legacySerializedBackupWorkspaces.emptyWorkspaceInfos : [],
};
} catch (error) {
if (error.code !== 'ENOENT') {
Expand All @@ -89,7 +93,7 @@ export class BackupMainService implements IBackupMainService {
}
}

return serializedBackupWorkspaces ?? Object.create(null);
return serializedBackupWorkspaces ?? { workspaces: [], folders: [], emptyWindows: [] };
}

protected getWorkspaceBackups(): IWorkspaceBackupInfo[] {
Expand Down

0 comments on commit f54c237

Please sign in to comment.