提交 4968e0a7 编写于 作者: B Benjamin Pasero

fix #77419

上级 88e570c5
...@@ -111,15 +111,10 @@ export class BackupFileService implements IBackupFileService { ...@@ -111,15 +111,10 @@ export class BackupFileService implements IBackupFileService {
private impl: IBackupFileService; private impl: IBackupFileService;
constructor( constructor(
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService, @IWorkbenchEnvironmentService private environmentService: IWorkbenchEnvironmentService,
@IFileService fileService: IFileService @IFileService protected fileService: IFileService
) { ) {
const backupWorkspaceResource = environmentService.configuration.backupWorkspaceResource; this.initialize();
if (backupWorkspaceResource) {
this.impl = new BackupFileServiceImpl(backupWorkspaceResource, this.hashPath, fileService);
} else {
this.impl = new InMemoryBackupFileService(this.hashPath);
}
} }
protected hashPath(resource: URI): string { protected hashPath(resource: URI): string {
...@@ -128,9 +123,25 @@ export class BackupFileService implements IBackupFileService { ...@@ -128,9 +123,25 @@ export class BackupFileService implements IBackupFileService {
return hash(str).toString(16); return hash(str).toString(16);
} }
initialize(backupWorkspaceResource: URI): void { private initialize(): void {
const backupWorkspaceResource = this.environmentService.configuration.backupWorkspaceResource;
if (backupWorkspaceResource) {
this.impl = new BackupFileServiceImpl(backupWorkspaceResource, this.hashPath, this.fileService);
} else {
this.impl = new InMemoryBackupFileService(this.hashPath);
}
}
reinitialize(): void {
// Re-init implementation (unless we are running in-memory)
if (this.impl instanceof BackupFileServiceImpl) { if (this.impl instanceof BackupFileServiceImpl) {
this.impl.initialize(backupWorkspaceResource); const backupWorkspaceResource = this.environmentService.configuration.backupWorkspaceResource;
if (backupWorkspaceResource) {
this.impl.initialize(backupWorkspaceResource);
} else {
this.impl = new InMemoryBackupFileService(this.hashPath);
}
} }
} }
......
...@@ -397,11 +397,15 @@ export class WorkspaceEditingService implements IWorkspaceEditingService { ...@@ -397,11 +397,15 @@ export class WorkspaceEditingService implements IWorkspaceEditingService {
const result = await this.windowService.enterWorkspace(path); const result = await this.windowService.enterWorkspace(path);
if (result) { if (result) {
// Migrate storage to new workspace
await this.migrateStorage(result.workspace); await this.migrateStorage(result.workspace);
// Reinitialize backup service // Reinitialize backup service
this.environmentService.configuration.backupPath = result.backupPath;
this.environmentService.configuration.backupWorkspaceResource = result.backupPath ? toBackupWorkspaceResource(result.backupPath, this.environmentService) : undefined;
if (this.backupFileService instanceof BackupFileService) { if (this.backupFileService instanceof BackupFileService) {
this.backupFileService.initialize(toBackupWorkspaceResource(result.backupPath!, this.environmentService)); this.backupFileService.reinitialize();
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册