src/vs/workbench/services/workingCopy/common/workingCopyBackupService.ts/NativeWorkingCopyBackupServiceImpl/resolve
class NativeWorkingCopyBackupServiceImpl:	async resolve<T extends IWorkingCopyBackupMeta>(identifier: IWorkingCopyIdentifier): Promise<IResolvedWorkingCopyBackup<T> | undefined> {
		const backupResource = this.toBackupResource(identifier);

		const model = await this.ready;
		if (!model.has(backupResource)) {
			return undefined; // require backup to be present
		}

		// Load the backup content and peek into the first chunk
		// to be able to resolve the meta data
		const backupStream = await this.fileService.readFileStream(backupResource);
		const peekedBackupStream = await peekStream(backupStream.value, 1);
		const firstBackupChunk = VSBuffer.concat(peekedBackupStream.buffer);

		// We have seen reports (e.g. https://github.com/microsoft/vscode/issues/78500) where
		// if VSCode goes down while writing the backup file, the file can turn empty because
		// it always first gets truncated and then written to. In this case, we will not find
		// the meta-end marker ('\n') and as such the backup can only be invalid. We bail out
		// here if that is the case.
		const preambleEndIndex = firstBackupChunk.buffer.indexOf(NativeWorkingCopyBackupServiceImpl.PREAMBLE_END_MARKER_CHARCODE);
		if (preambleEndIndex === -1) {
			this.logService.trace(`Backup: Could not find meta end marker in ${backupResource}. The file is probably corrupt (filesize: ${backupStream.size}).`);

			return undefined;
		}

		const preambelRaw = firstBackupChunk.slice(0, preambleEndIndex).toString();

		// Extract meta data (if any)
		let meta: T | undefined;
		const metaStartIndex = preambelRaw.indexOf(NativeWorkingCopyBackupServiceImpl.PREAMBLE_META_SEPARATOR);
		if (metaStartIndex !== -1) {
			try {
				meta = JSON.parse(preambelRaw.substr(metaStartIndex + 1));

				// `typeId` is a property that we add so we
				// remove it when returning to clients.
				if (typeof meta?.typeId === 'string') {
					delete meta.typeId;

					if (isEmptyObject(meta)) {
						meta = undefined;
					}
				}
			} catch (error) {
				// ignore JSON parse errors
			}
		}

		// Build a new stream without the preamble
		const firstBackupChunkWithoutPreamble = firstBackupChunk.slice(preambleEndIndex + 1);
		let value: VSBufferReadableStream;
		if (peekedBackupStream.ended) {
			value = bufferToStream(firstBackupChunkWithoutPreamble);
		} else {
			value = prefixedBufferStream(firstBackupChunkWithoutPreamble, peekedBackupStream.stream);
		}

		return { value, meta };
	}