Merge from vscode 79a1f5a5ca0c6c53db617aa1fa5a2396d2caebe2

This commit is contained in:
ADS Merger
2020-05-31 19:47:51 +00:00
parent 84492049e8
commit 28be33cfea
913 changed files with 28242 additions and 15549 deletions

View File

@@ -322,15 +322,16 @@ class BackupFileServiceImpl extends Disposable implements IBackupFileService {
return coalesce(backups);
}
private async readToMatchingString(file: URI, matchingString: string, maximumBytesToRead: number): Promise<string> {
private async readToMatchingString(file: URI, matchingString: string, maximumBytesToRead: number): Promise<string | undefined> {
const contents = (await this.fileService.readFile(file, { length: maximumBytesToRead })).value.toString();
const newLineIndex = contents.indexOf(matchingString);
if (newLineIndex >= 0) {
return contents.substr(0, newLineIndex);
const matchingStringIndex = contents.indexOf(matchingString);
if (matchingStringIndex >= 0) {
return contents.substr(0, matchingStringIndex);
}
throw new Error(`Backup: Could not find ${JSON.stringify(matchingString)} in first ${maximumBytesToRead} bytes of ${file}`);
// Unable to find matching string in file
return undefined;
}
async resolve<T extends object>(resource: URI): Promise<IResolvedBackup<T> | undefined> {
@@ -387,7 +388,7 @@ class BackupFileServiceImpl extends Disposable implements IBackupFileService {
// the meta-end marker ('\n') and as such the backup can only be invalid. We bail out
// here if that is the case.
if (!metaEndFound) {
this.logService.error(`Backup: Could not find meta end marker in ${backupResource}. The file is probably corrupt.`);
this.logService.trace(`Backup: Could not find meta end marker in ${backupResource}. The file is probably corrupt (filesize: ${content.size}).`);
return undefined;
}