Skip to content

Commit 2a88776

Browse files
committed
make backupWorkspaceResource an user data resource
1 parent 19d674f commit 2a88776

4 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/vs/workbench/services/backup/common/backup.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import { URI } from 'vs/base/common/uri';
77
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
88
import { ITextBufferFactory, ITextSnapshot } from 'vs/editor/common/model';
9+
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
10+
import { joinPath, relativePath } from 'vs/base/common/resources';
911

1012
export const IBackupFileService = createDecorator<IBackupFileService>('backupFileService');
1113

@@ -80,3 +82,7 @@ export interface IBackupFileService {
8082
*/
8183
discardAllWorkspaceBackups(): Promise<void>;
8284
}
85+
86+
export function toBackupWorkspaceResource(backupWorkspacePath: string, environmentService: IEnvironmentService): URI {
87+
return joinPath(environmentService.userRoamingDataHome, relativePath(URI.file(environmentService.userDataPath), URI.file(backupWorkspacePath))!);
88+
}

src/vs/workbench/services/backup/common/backupFileService.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { join } from 'vs/base/common/path';
7-
import { joinPath, relativePath } from 'vs/base/common/resources';
7+
import { joinPath } from 'vs/base/common/resources';
88
import { URI } from 'vs/base/common/uri';
99
import { hash } from 'vs/base/common/hash';
1010
import { coalesce } from 'vs/base/common/arrays';
@@ -116,7 +116,7 @@ export class BackupFileService implements IBackupFileService {
116116
) {
117117
const backupWorkspaceResource = environmentService.configuration.backupWorkspaceResource;
118118
if (backupWorkspaceResource) {
119-
this.impl = new BackupFileServiceImpl(backupWorkspaceResource, this.hashPath, environmentService, fileService);
119+
this.impl = new BackupFileServiceImpl(backupWorkspaceResource, this.hashPath, fileService);
120120
} else {
121121
this.impl = new InMemoryBackupFileService(this.hashPath);
122122
}
@@ -183,7 +183,6 @@ class BackupFileServiceImpl implements IBackupFileService {
183183
constructor(
184184
backupWorkspaceResource: URI,
185185
private readonly hashPath: (resource: URI) => string,
186-
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
187186
@IFileService private readonly fileService: IFileService
188187
) {
189188
this.isShuttingDown = false;
@@ -193,7 +192,7 @@ class BackupFileServiceImpl implements IBackupFileService {
193192
}
194193

195194
initialize(backupWorkspaceResource: URI): void {
196-
this.backupWorkspacePath = joinPath(this.environmentService.userRoamingDataHome, relativePath(URI.file(this.environmentService.userDataPath), backupWorkspaceResource)!);
195+
this.backupWorkspacePath = backupWorkspaceResource;
197196

198197
this.ready = this.init();
199198
}

src/vs/workbench/services/environment/node/environmentService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
99
import { memoize } from 'vs/base/common/decorators';
1010
import { URI } from 'vs/base/common/uri';
1111
import { Schemas } from 'vs/base/common/network';
12+
import { toBackupWorkspaceResource } from 'vs/workbench/services/backup/common/backup';
1213

1314
export class WorkbenchEnvironmentService extends EnvironmentService implements IWorkbenchEnvironmentService {
1415

@@ -19,7 +20,7 @@ export class WorkbenchEnvironmentService extends EnvironmentService implements I
1920
execPath: string
2021
) {
2122
super(_configuration, execPath);
22-
this._configuration.backupWorkspaceResource = this._configuration.backupPath ? URI.file(this._configuration.backupPath) : undefined;
23+
this._configuration.backupWorkspaceResource = this._configuration.backupPath ? toBackupWorkspaceResource(this._configuration.backupPath, this) : undefined;
2324
}
2425

2526
get configuration(): IWindowConfiguration {

src/vs/workbench/services/workspace/electron-browser/workspaceEditingService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { StorageService } from 'vs/platform/storage/node/storageService';
1616
import { ConfigurationScope, IConfigurationRegistry, Extensions as ConfigurationExtensions, IConfigurationPropertySchema } from 'vs/platform/configuration/common/configurationRegistry';
1717
import { Registry } from 'vs/platform/registry/common/platform';
1818
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
19-
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
19+
import { IBackupFileService, toBackupWorkspaceResource } from 'vs/workbench/services/backup/common/backup';
2020
import { BackupFileService } from 'vs/workbench/services/backup/common/backupFileService';
2121
import { ICommandService } from 'vs/platform/commands/common/commands';
2222
import { distinct } from 'vs/base/common/arrays';
@@ -397,7 +397,7 @@ export class WorkspaceEditingService implements IWorkspaceEditingService {
397397
await this.migrateStorage(result.workspace);
398398
// Reinitialize backup service
399399
if (this.backupFileService instanceof BackupFileService) {
400-
this.backupFileService.initialize(URI.file(result.backupPath!));
400+
this.backupFileService.initialize(toBackupWorkspaceResource(result.backupPath!, this.environmentService));
401401
}
402402
}
403403

0 commit comments

Comments
 (0)