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

fix #77419

上级 88e570c5
......@@ -111,15 +111,10 @@ export class BackupFileService implements IBackupFileService {
private impl: IBackupFileService;
constructor(
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IFileService fileService: IFileService
@IWorkbenchEnvironmentService private environmentService: IWorkbenchEnvironmentService,
@IFileService protected fileService: IFileService
) {
const backupWorkspaceResource = environmentService.configuration.backupWorkspaceResource;
if (backupWorkspaceResource) {
this.impl = new BackupFileServiceImpl(backupWorkspaceResource, this.hashPath, fileService);
} else {
this.impl = new InMemoryBackupFileService(this.hashPath);
}
this.initialize();
}
protected hashPath(resource: URI): string {
......@@ -128,9 +123,25 @@ export class BackupFileService implements IBackupFileService {
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) {
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 {
const result = await this.windowService.enterWorkspace(path);
if (result) {
// Migrate storage to new workspace
await this.migrateStorage(result.workspace);
// 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) {
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.
先完成此消息的编辑!
想要评论请 注册