From d2c3cffb6ead4b7ff88786867b7deb07af310ce3 Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Sun, 7 Aug 2022 23:20:42 -0400 Subject: [PATCH] Only copy cached index from root if it does not exist locally --- src/main.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 28b0124..f9aca0d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -109,15 +109,19 @@ impl Debug for FileTree { impl FileTree { fn load_or_build(root_path: &Path, cache_path: &Path) -> SerdeResult { - 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)