Stream native failure manifests during publication

This commit is contained in:
gloamxun committed 2026-11-19 14:50:11 +08:00
1 parent 72ed779749
commit 5aa7dc7331
5 files changed
+46 -9

No files matched your search

+11 -1
View File
@@ -1855,8 +1855,18 @@ impl PreparedOutput {
Ok(version)
}
pub fn write(output: &Path, bytes: &[u8]) -> Result<Self, String> {
Self::write_with(output, |file| {
file.write_all(bytes).map_err(|error| error.to_string())
})
}
pub(crate) fn write_with(
output: &Path,
write: impl FnOnce(&mut File) -> Result<(), String>,
) -> Result<Self, String> {
let (prepared, mut file) = Self::create(output)?;
let written = file.write_all(bytes).and_then(|()| file.sync_all());
let written = write(&mut file)
.and_then(|()| file.sync_all().map_err(|error| error.to_string()));
drop(file);
written.map_err(|error| format!("stage output {}: {error}", output.display()))?;
Ok(prepared)