From 63914c995a238f2abf5a32f0785aef40ca205f10 Mon Sep 17 00:00:00 2001 From: james58899 Date: Tue, 17 Dec 2024 09:41:37 +0000 Subject: [PATCH] Comment --- src/cache_manager.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/cache_manager.rs b/src/cache_manager.rs index da35036..aa7cc61 100644 --- a/src/cache_manager.rs +++ b/src/cache_manager.rs @@ -119,14 +119,13 @@ impl CacheManager { pub async fn get_file(self: &Arc, info: &CacheFileInfo) -> Option>> { let path = info.to_path(&self.cache_dir); - let metadata = metadata(&path).await.ok()?; - // Check file exists + // Check exists and open file + let metadata = metadata(&path).await.ok()?; if !metadata.is_file() || metadata.len() != info.size() as u64 { warn!("Unexcepted cache file metadata: type={:?}, size={}", metadata.file_type(), metadata.len()); return None; } - let mut file = match File::open(&path).await { Ok(file) => file, Err(err) => { @@ -135,7 +134,7 @@ impl CacheManager { } }; - // Skip check if file is recently accessed + // Skip hash check if file is recently accessed let one_week_ago = SystemTime::now() - Duration::from_secs(60 * 60 * 24 * 7); if FileTime::from_last_modification_time(&metadata) >= one_week_ago.into() { return Some(ReaderStream::with_capacity(file, 64 * 1024).boxed());