提交 896dd922 编写于 作者: D Daniel Imms

Fix remaining case where workspace paths are lower cased

Fixes #16829
上级 2b288227
......@@ -117,16 +117,16 @@ export class BackupMainService implements IBackupMainService {
this.validateBackupWorkspaces(backups);
}
protected sanitizeFolderWorkspaces(backups: IBackupWorkspacesFormat): void {
// Merge duplicates for folder workspaces, don't worry about cleaning them up as they will
// be removed when there are no backups.
backups.folderWorkspaces = arrays.distinct(backups.folderWorkspaces.map(w => this.sanitizePath(w)));
protected dedupeFolderWorkspaces(backups: IBackupWorkspacesFormat): void {
// De-duplicate folder workspaces, don't worry about cleaning them up any duplicates as
// they will be removed when there are no backups.
backups.folderWorkspaces = arrays.distinct(backups.folderWorkspaces, ws => this.sanitizePath(ws));
}
private validateBackupWorkspaces(backups: IBackupWorkspacesFormat): void {
const staleBackupWorkspaces: { workspaceIdentifier: string; backupPath: string; isEmptyWorkspace: boolean }[] = [];
this.sanitizeFolderWorkspaces(backups);
this.dedupeFolderWorkspaces(backups);
backups.folderWorkspaces.forEach(workspacePath => {
const backupPath = path.join(this.backupHome, this.getWorkspaceHash(workspacePath));
......
......@@ -36,8 +36,8 @@ class TestBackupMainService extends BackupMainService {
super.loadSync();
}
public sanitizeFolderWorkspaces(backups: IBackupWorkspacesFormat): void {
super.sanitizeFolderWorkspaces(backups);
public dedupeFolderWorkspaces(backups: IBackupWorkspacesFormat): void {
super.dedupeFolderWorkspaces(backups);
}
public toBackupPath(workspacePath: string): string {
......@@ -209,24 +209,25 @@ suite('BackupMainService', () => {
});
});
suite('sanitizeFolderWorkspaces', () => {
test('should merge same cased paths on Windows and Mac', () => {
suite('dedupeFolderWorkspaces', () => {
test('should ignore duplicates on Windows and Mac', () => {
// Skip test on Linux
if (platform.isLinux) {
return;
}
const backups: IBackupWorkspacesFormat = {
folderWorkspaces: platform.isWindows ? ['c:\\foo', 'C:\\FOO', 'c:\\FOO'] : ['/foo', '/FOO'],
folderWorkspaces: platform.isWindows ? ['c:\\FOO', 'C:\\FOO', 'c:\\foo'] : ['/FOO', '/foo'],
emptyWorkspaces: []
};
service.sanitizeFolderWorkspaces(backups);
service.dedupeFolderWorkspaces(backups);
assert.equal(backups.folderWorkspaces.length, 1);
if (platform.isWindows) {
assert.deepEqual(backups.folderWorkspaces, ['c:\\foo']);
assert.deepEqual(backups.folderWorkspaces, ['c:\\FOO'], 'should return the first duplicated entry');
} else {
assert.deepEqual(backups.folderWorkspaces, ['/foo']);
assert.deepEqual(backups.folderWorkspaces, ['/FOO'], 'should return the first duplicated entry');
}
});
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册