fix: write reference sources before fingerprints.json, atomic on failure

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-30 02:59:27 +02:00
co-authored by Claude Opus 5.5
parent ed806a1cc8
commit 4b619d12e9
2 changed files with 45 additions and 10 deletions
+14 -6
View File
@@ -172,13 +172,21 @@ final class DiviCheckCommand
return 1;
}
DiviReference::writeExpected(
array_map(static fn (SourceFingerprint $print): string => $print->hash, $prints),
$this->expectedFile
);
$sourceDir = ($this->sourceDir ?? DiviReference::sourceDir(...))();
foreach ($sourceDir === null ? [] : $prints as $id => $print) {
DiviReference::writeSource($id, $print->source, $sourceDir);
try {
// Sources first, fingerprints.json last: the fingerprints decide the release gate, so a write that
// fails before this last one leaves the gate exactly as it was.
foreach ($sourceDir === null ? [] : $prints as $id => $print) {
DiviReference::writeSource($id, $print->source, $sourceDir);
}
DiviReference::writeExpected(
array_map(static fn (SourceFingerprint $print): string => $print->hash, $prints),
$this->expectedFile
);
} catch (RuntimeException $e) {
($this->out)('Referenz nicht vollständig aktualisiert: ' . $e->getMessage());
return 1;
}
delete_transient(ReleaseResolver::CACHE);
ReleaseGate::forget();