mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-20 02:34:37 +01:00
backup - let discardAllBackups() delete backup folder for workspace again
This commit is contained in:
@@ -278,9 +278,18 @@ class BackupFileServiceImpl extends Disposable implements IBackupFileService {
|
||||
}
|
||||
|
||||
async discardAllBackups(): Promise<void> {
|
||||
const model = await this.ready;
|
||||
|
||||
// Discard each backup and clear model
|
||||
// We go through the doDiscardBackup()
|
||||
// method to benefit from the IO queue
|
||||
const model = await this.ready;
|
||||
await Promise.all(model.get().map(backupResource => this.doDiscardBackup(backupResource)));
|
||||
model.clear();
|
||||
|
||||
// Delete the backup home for this workspace
|
||||
// It will automatically be populated again
|
||||
// once another backup is made
|
||||
await this.deleteIgnoreFileNotFound(this.backupWorkspacePath);
|
||||
}
|
||||
|
||||
private async deleteIgnoreFileNotFound(resource: URI): Promise<void> {
|
||||
|
||||
@@ -292,6 +292,7 @@ suite('BackupFileService', () => {
|
||||
await service.discardAllBackups();
|
||||
assert.equal(fs.existsSync(fooBackupPath), false);
|
||||
assert.equal(fs.existsSync(barBackupPath), false);
|
||||
assert.equal(fs.existsSync(path.join(workspaceBackupPath, 'file')), false);
|
||||
});
|
||||
|
||||
test('untitled file', async () => {
|
||||
@@ -299,6 +300,7 @@ suite('BackupFileService', () => {
|
||||
assert.equal(fs.readdirSync(path.join(workspaceBackupPath, 'untitled')).length, 1);
|
||||
await service.discardAllBackups();
|
||||
assert.equal(fs.existsSync(untitledBackupPath), false);
|
||||
assert.equal(fs.existsSync(path.join(workspaceBackupPath, 'untitled')), false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user