Only copy cached index from root if it does not exist locally
This commit is contained in:
parent
0ddbc9dace
commit
d2c3cffb6e
12
src/main.rs
12
src/main.rs
@ -109,15 +109,19 @@ impl Debug for FileTree {
|
||||
|
||||
impl FileTree {
|
||||
fn load_or_build(root_path: &Path, cache_path: &Path) -> SerdeResult<Self> {
|
||||
let root_index = root_path.join(INDEX_NAME);
|
||||
let path = cache_path.join(INDEX_NAME);
|
||||
if root_index.exists() {
|
||||
std::fs::copy(&root_index, &path)?;
|
||||
}
|
||||
match FileTree::load(&path) {
|
||||
Ok(tree) => return Ok(tree),
|
||||
Err(e) => warn!("error loading {:?}: {:?}", path, e),
|
||||
}
|
||||
let root_index = root_path.join(INDEX_NAME);
|
||||
if root_index.exists() {
|
||||
std::fs::copy(&root_index, &path)?;
|
||||
match FileTree::load(&path) {
|
||||
Ok(tree) => return Ok(tree),
|
||||
Err(e) => warn!("error loading {:?}: {:?}", path, e),
|
||||
}
|
||||
}
|
||||
let tree = FileTree::build(root_path);
|
||||
tree.save(&path)?;
|
||||
Ok(tree)
|
||||
|
Loading…
Reference in New Issue
Block a user