diff --git a/src/vs/platform/windows/common/windows.ts b/src/vs/platform/windows/common/windows.ts index 1f64adccc5b..d9e25ebfa2c 100644 --- a/src/vs/platform/windows/common/windows.ts +++ b/src/vs/platform/windows/common/windows.ts @@ -419,6 +419,7 @@ export interface IWindowConfiguration extends ParsedArgs { nodeCachedDataDir?: string; backupPath?: string; + backupWorkspaceResource?: URI; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; diff --git a/src/vs/workbench/services/backup/common/backupFileService.ts b/src/vs/workbench/services/backup/common/backupFileService.ts index bb3cba3455f..7571d65ba6a 100644 --- a/src/vs/workbench/services/backup/common/backupFileService.ts +++ b/src/vs/workbench/services/backup/common/backupFileService.ts @@ -114,9 +114,9 @@ export class BackupFileService implements IBackupFileService { @IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService, @IFileService fileService: IFileService ) { - const backupWorkspacePath = environmentService.configuration.backupPath; - if (backupWorkspacePath) { - this.impl = new BackupFileServiceImpl(backupWorkspacePath, this.hashPath, environmentService, fileService); + const backupWorkspaceResource = environmentService.configuration.backupWorkspaceResource; + if (backupWorkspaceResource) { + this.impl = new BackupFileServiceImpl(backupWorkspaceResource, this.hashPath, environmentService, fileService); } else { this.impl = new InMemoryBackupFileService(this.hashPath); } @@ -127,9 +127,9 @@ export class BackupFileService implements IBackupFileService { return hash(str).toString(16); } - initialize(backupWorkspacePath: string): void { + initialize(backupWorkspaceResource: URI): void { if (this.impl instanceof BackupFileServiceImpl) { - this.impl.initialize(backupWorkspacePath); + this.impl.initialize(backupWorkspaceResource); } } @@ -181,7 +181,7 @@ class BackupFileServiceImpl implements IBackupFileService { private ioOperationQueues: ResourceQueue; // queue IO operations to ensure write order constructor( - backupWorkspacePath: string, + backupWorkspaceResource: URI, private readonly hashPath: (resource: URI) => string, @IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService, @IFileService private readonly fileService: IFileService @@ -189,11 +189,11 @@ class BackupFileServiceImpl implements IBackupFileService { this.isShuttingDown = false; this.ioOperationQueues = new ResourceQueue(); - this.initialize(backupWorkspacePath); + this.initialize(backupWorkspaceResource); } - initialize(backupWorkspacePath: string): void { - this.backupWorkspacePath = joinPath(this.environmentService.userRoamingDataHome, relativePath(URI.file(this.environmentService.userDataPath), URI.file(backupWorkspacePath))!); + initialize(backupWorkspaceResource: URI): void { + this.backupWorkspacePath = joinPath(this.environmentService.userRoamingDataHome, relativePath(URI.file(this.environmentService.userDataPath), backupWorkspaceResource)!); this.ready = this.init(); } diff --git a/src/vs/workbench/services/environment/node/environmentService.ts b/src/vs/workbench/services/environment/node/environmentService.ts index 48be78c71f7..666d4f42506 100644 --- a/src/vs/workbench/services/environment/node/environmentService.ts +++ b/src/vs/workbench/services/environment/node/environmentService.ts @@ -19,6 +19,7 @@ export class WorkbenchEnvironmentService extends EnvironmentService implements I execPath: string ) { super(_configuration, execPath); + this._configuration.backupWorkspaceResource = this._configuration.backupPath ? URI.file(this._configuration.backupPath) : undefined; } get configuration(): IWindowConfiguration { diff --git a/src/vs/workbench/services/workspace/electron-browser/workspaceEditingService.ts b/src/vs/workbench/services/workspace/electron-browser/workspaceEditingService.ts index 8d8bacc2b13..7bd45172d26 100644 --- a/src/vs/workbench/services/workspace/electron-browser/workspaceEditingService.ts +++ b/src/vs/workbench/services/workspace/electron-browser/workspaceEditingService.ts @@ -397,7 +397,7 @@ export class WorkspaceEditingService implements IWorkspaceEditingService { await this.migrateStorage(result.workspace); // Reinitialize backup service if (this.backupFileService instanceof BackupFileService) { - this.backupFileService.initialize(result.backupPath!); + this.backupFileService.initialize(URI.file(result.backupPath!)); } }