Skip to content

Commit

Permalink
fixed cornercase of not even unstamped db files existing
Browse files Browse the repository at this point in the history
  • Loading branch information
djugei committed Jan 30, 2025
1 parent 41a0dff commit 52ca8c2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions client/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ pub async fn sync_db(server: Url, name: Str, client: Client, _multi: MultiProgre
info!("{name}: old ({old_ts}) == new ({new_ts}), nothing to do");
}
} else {
info!("no previous db found, do full timestamped download");
info!("no timestamped db found, do full download");
//TODO: maybe share this block between the two branches
let url = server.join(&format!("{name}"))?;
let mut response = client.get(url).send().await?;
Expand All @@ -303,9 +303,15 @@ pub async fn sync_db(server: Url, name: Str, client: Client, _multi: MultiProgre
new.write_all(&chunk).await?;
}

trace!("linking {new_p} to db");
let db_p = format!("/var/lib/pacman/sync/{name}.db");
std::fs::remove_file(&db_p)?;
trace!("linking {new_p} to {db_p}");
let res = std::fs::remove_file(&db_p);
if let Err(e) = res {
// Not found is fine, just means the db does not exist yet
if e.kind() != std::io::ErrorKind::NotFound {
bail!(e);
}
}
std::os::unix::fs::symlink(new_p, db_p)?;
info!("finished downloading {name} at {new_ts}");
}
Expand Down

0 comments on commit 52ca8c2

Please sign in to comment.