提交 dc298f06 编写于 作者: D Daniel Imms

Cover other cases

上级 d3c5d1f1
......@@ -160,4 +160,19 @@ suite('BackupMainService', () => {
done();
});
test('toBackupPath ignores case on Windows and Mac', () => {
// Skip test on Linux
if (platform.isLinux) {
return;
}
if (platform.isMacintosh) {
assert.equal(service.toBackupPath('/foo'), service.toBackupPath('/FOO'));
}
if (platform.isWindows) {
assert.equal(service.toBackupPath('c:\\foo'), service.toBackupPath('C:\\FOO'));
}
});
});
\ No newline at end of file
......@@ -101,8 +101,7 @@ export class BackupFileService implements IBackupFileService {
this.workspacesJsonPath = environmentService.backupWorkspacesPath;
if (this.currentWorkspace) {
const workspaceHash = crypto.createHash('md5').update(this.currentWorkspace.fsPath).digest('hex');
this.backupWorkspacePath = path.join(this.backupHome, workspaceHash);
this.backupWorkspacePath = path.join(this.backupHome, this.hashPath(this.currentWorkspace));
}
this.ready = this.init();
......@@ -213,12 +212,13 @@ export class BackupFileService implements IBackupFileService {
return null;
}
// Windows and Mac paths are case insensitive, we want backups to be too
const pathCaseFix = platform.isWindows || platform.isMacintosh ? resource.fsPath.toLowerCase() : resource.fsPath;
return Uri.file(path.join(this.backupWorkspacePath, resource.scheme, this.hashPath(resource)));
}
const backupName = crypto.createHash('md5').update(pathCaseFix).digest('hex');
const backupPath = path.join(this.backupWorkspacePath, resource.scheme, backupName);
private hashPath(resource: Uri): string {
// Windows and Mac paths are case insensitive, we want backups to be too
const caseAwarePath = platform.isWindows || platform.isMacintosh ? resource.fsPath.toLowerCase() : resource.fsPath;
return Uri.file(backupPath);
return crypto.createHash('md5').update(caseAwarePath).digest('hex');
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册