fix: make snapshot file read errors non-fatal

This commit is contained in:
Ilya Zlobintsev 2024-01-12 19:17:24 +02:00
parent b107a83bb3
commit abef69c852

View File

@ -585,9 +585,8 @@ fn add_path_to_archive(
if let Ok(metadata) = std::fs::metadata(full_path) {
debug!("adding {full_path:?} to snapshot");
let data = std::fs::read(full_path)
.with_context(|| format!("Could not read file at {full_path:?}"))?;
match std::fs::read(full_path) {
Ok(data) => {
let mut header = tar::Header::new_gnu();
header.set_size(data.len().try_into().unwrap());
header.set_mode(metadata.mode());
@ -599,5 +598,10 @@ fn add_path_to_archive(
.append_data(&mut header, archive_path, Cursor::new(data))
.context("Could not write data to archive")?;
}
Err(err) => {
warn!("file {full_path:?} exists, but could not be added to snapshot: {err}");
}
}
}
Ok(())
}