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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user