in src/main.rs [265:297]
fn patch_uninstdat(
log: &slog::Logger,
uninstdat_path: &PathBuf,
update_folder_name: &str,
) -> Result<(), Box<dyn error::Error>> {
let (header, recs) = read_file(&uninstdat_path)?;
info!(log, "header: {:?}", header);
info!(log, "num_recs: {:?}", recs.len());
let root_path = uninstdat_path.parent().ok_or(io::Error::new(
io::ErrorKind::Other,
"Could not get parent path of uninstdat",
))?;
let mut update_path = PathBuf::from(root_path);
update_path.push(&update_folder_name);
let recs: Result<Vec<FileRec>, _> = recs
.iter()
.map(|rec| match rec.typ {
model::UninstallRecTyp::DeleteDirOrFiles | model::UninstallRecTyp::DeleteFile => {
rec.rebase(&update_path)
}
_ => Ok(rec.clone()),
})
.collect();
info!(log, "Updating uninstall file {:?}", uninstdat_path);
write_file(&uninstdat_path, &header, recs?)?;
Ok(())
}