M2: cursor-based resumable runs with merge-join against the parent
TreeWalker walks one or more roots in a stable segment-wise order with exclusions and resumes after a cursor; ParentCursor merge-joins the previous snapshot in the same order. BackupRun no longer keeps a file list or the parent's entries in memory or in its state.
This commit is contained in:
@@ -342,6 +342,23 @@ final class Repository {
|
||||
return $map;
|
||||
}
|
||||
|
||||
/** @return \Generator<array{p:string, s:int, m:int, b:list<string>}> entries of a snapshot, in stored order */
|
||||
public function entries(string $snapshotId): \Generator {
|
||||
return $this->streamEntries($snapshotId);
|
||||
}
|
||||
|
||||
/** The meta record (first line) of a snapshot. */
|
||||
public function snapshotMeta(string $snapshotId): array {
|
||||
$plain = fopen('php://temp/maxmemory:' . (4 * 1048576), 'w+b');
|
||||
$fh = $this->backend->get('snapshots/' . $snapshotId);
|
||||
$this->cipher->decrypt($fh, $plain, 'snapshot:' . $snapshotId);
|
||||
fclose($fh);
|
||||
rewind($plain);
|
||||
$meta = json_decode((string)fgets($plain), true, 512, JSON_THROW_ON_ERROR);
|
||||
fclose($plain);
|
||||
return $meta;
|
||||
}
|
||||
|
||||
/** @return \Generator<array{p:string, s:int, m:int, b:list<string>}> */
|
||||
private function streamEntries(string $snapshotId): \Generator {
|
||||
$plain = fopen('php://temp/maxmemory:' . (4 * 1048576), 'w+b');
|
||||
|
||||
Reference in New Issue
Block a user