mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-12 02:58:31 -05:00
Merge from vscode 79a1f5a5ca0c6c53db617aa1fa5a2396d2caebe2
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user