Skip to content

Commit

Permalink
fix: apply #323 to SessionBuilder::commit_from_url
Browse files Browse the repository at this point in the history
  • Loading branch information
decahedron1 committed Nov 29, 2024
1 parent 5d41c96 commit 7b08bac
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/session/builder/impl_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@ impl SessionBuilder {

match std::fs::rename(&temp_filepath, &model_filepath) {
Ok(()) => model_filepath,
Err(e) => match e.kind() {
std::io::ErrorKind::AlreadyExists => {
Err(e) => {
if model_filepath.exists() {
let _ = std::fs::remove_file(temp_filepath);
model_filepath
} else {
return Err(Error::new(format!("Failed to download model: {e}")));
}
_ => return Err(Error::new(format!("Failed to download model: {e}")))
}
}
};
Expand Down

0 comments on commit 7b08bac

Please sign in to comment.