This commit is contained in:
Ubuntu
2023-06-27 17:24:26 +00:00
parent 8b4b2d1830
commit e29dae044d
5 changed files with 229 additions and 85 deletions

View File

@ -53,7 +53,11 @@ impl Cache {
let commit_hash = std::fs::read_to_string(commit_path).ok()?;
let mut pointer_path = self.pointer_path(repo, &commit_hash);
pointer_path.push(filename);
Some(pointer_path)
if pointer_path.exists(){
Some(pointer_path)
}else{
None
}
}
/// Creates a reference in the cache directory that points branches to the correct
@ -146,7 +150,12 @@ impl Repo {
/// The normalized folder nameof the repo within the cache directory
pub fn folder_name(&self) -> String {
self.repo_id.replace('/', "--")
let prefix = match self.repo_type{
RepoType::Model => "models",
RepoType::Dataset => "datasets",
RepoType::Space => "spaces",
};
format!("{prefix}--{}", self.repo_id).replace('/', "--")
}
/// The revision