提交 2d4122ac 编写于 作者: D Daniel Imms

Use a per-resource queue

上级 4ad8922e
......@@ -98,7 +98,7 @@ export class BackupFileService implements IBackupFileService {
private isShuttingDown: boolean;
private backupWorkspacePath: string;
private ready: TPromise<IBackupFilesModel>;
private ioQueue: Queue<void>;
private ioOperationQueues: { [path: string]: Queue<void> };
constructor(
@IEnvironmentService private environmentService: IEnvironmentService,
......@@ -108,7 +108,7 @@ export class BackupFileService implements IBackupFileService {
) {
this.isShuttingDown = false;
this.ready = this.init(windowService.getCurrentWindowId());
this.ioQueue = new Queue<void>();
this.ioOperationQueues = {};
}
private get backupEnabled(): boolean {
......@@ -176,7 +176,7 @@ export class BackupFileService implements IBackupFileService {
// Add metadata to top of file
content = `${resource.toString()}${BackupFileService.META_MARKER}${content}`;
return this.ioQueue.queue(() => {
return this.getResourceIOQueue(backupResource).queue(() => {
return this.fileService.updateContent(backupResource, content, BACKUP_FILE_UPDATE_OPTIONS).then(() => model.add(backupResource, versionId));
});
});
......@@ -189,12 +189,20 @@ export class BackupFileService implements IBackupFileService {
return void 0;
}
return this.ioQueue.queue(() => {
return this.getResourceIOQueue(backupResource).queue(() => {
return pfs.del(backupResource.fsPath).then(() => model.remove(backupResource));
});
});
}
private getResourceIOQueue(resource: Uri) {
const key = resource.toString();
if (!this.ioOperationQueues[key]) {
this.ioOperationQueues[key] = new Queue<void>();
}
return this.ioOperationQueues[key];
}
public discardAllWorkspaceBackups(): TPromise<void> {
this.isShuttingDown = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册