Browse Source

Only copy cached index from root if it does not exist locally

master
Travis Burtrum 2 months ago
parent
commit
d2c3cffb6e
  1. 12
      src/main.rs

12
src/main.rs

@ -109,15 +109,19 @@ impl Debug for FileTree { @@ -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…
Cancel
Save