From dc99437aec266812a5f9aaa281e9f2c00a95e291 Mon Sep 17 00:00:00 2001 From: Edward Shen Date: Thu, 15 Jul 2021 13:47:55 -0400 Subject: [PATCH] Fix legacy path lookup --- src/cache/disk.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cache/disk.rs b/src/cache/disk.rs index 1d18587..56c903f 100644 --- a/src/cache/disk.rs +++ b/src/cache/disk.rs @@ -282,7 +282,7 @@ impl TryFrom<&Path> for Md5Hash { impl From for PathBuf { fn from(hash: Md5Hash) -> Self { - let hex_value = dbg!(hash.to_hex_string()); + let hex_value = hash.to_hex_string(); let path = hex_value[0..3] .chars() .rev() @@ -309,17 +309,18 @@ impl Cache for DiskCache { let legacy_path = Md5Hash::try_from(path_0.as_path()) .map(PathBuf::from) + .map(|path| self.disk_path.clone().join(path)) .map(Arc::new); // Get file and path of first existing location path let (file, path) = if let Ok(legacy_path) = legacy_path { let maybe_files = join!( + File::open(legacy_path.as_path()), File::open(path.as_path()), - File::open(legacy_path.as_path()) ); match maybe_files { - (Ok(f), _) => Some((f, path)), - (_, Ok(f)) => Some((f, legacy_path)), + (Ok(f), _) => Some((f, legacy_path)), + (_, Ok(f)) => Some((f, path)), _ => return None, } } else {