Skip to content

Commit 800b6a1

Browse files
committed
better error handling in file cache
1 parent 7d139a6 commit 800b6a1

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/file_cache.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,19 @@ impl<T: AsyncFromStrWithState> FileCache<T> {
7979
log::trace!("Cache answer without filesystem lookup for {:?}", path);
8080
return Ok(Arc::clone(&cached.content));
8181
}
82-
if let Ok(modified) = tokio::fs::metadata(path).await.and_then(|m| m.modified()) {
83-
if modified <= cached.last_check_time() {
84-
log::trace!("Cache answer with filesystem metadata read for {:?}", path);
85-
cached.update_check_time();
86-
return Ok(Arc::clone(&cached.content));
82+
let modified_res = tokio::fs::metadata(path).await.and_then(|m| m.modified());
83+
match modified_res {
84+
Ok(modified) => {
85+
if modified <= cached.last_check_time() {
86+
log::trace!("Cache answer with filesystem metadata read for {:?}", path);
87+
cached.update_check_time();
88+
return Ok(Arc::clone(&cached.content));
89+
}
8790
}
91+
Err(e) => log::warn!(
92+
"Unable to check when '{}' was last modified. Re-reading the file: {e:#}",
93+
path.display()
94+
),
8895
}
8996
}
9097
// Read lock is released

0 commit comments

Comments
 (0)