Skip to content

Commit 7d139a6

Browse files
committed
Rune filesystem operations asynchronously
1 parent 74a50cd commit 7d139a6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/file_cache.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ 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) = std::fs::metadata(path).and_then(|m| m.modified()) {
82+
if let Ok(modified) = tokio::fs::metadata(path).await.and_then(|m| m.modified()) {
8383
if modified <= cached.last_check_time() {
8484
log::trace!("Cache answer with filesystem metadata read for {:?}", path);
8585
cached.update_check_time();
@@ -89,7 +89,8 @@ impl<T: AsyncFromStrWithState> FileCache<T> {
8989
}
9090
// Read lock is released
9191
log::trace!("Loading and parsing {:?}", path);
92-
let file_contents = std::fs::read_to_string(path)
92+
let file_contents = tokio::fs::read_to_string(path)
93+
.await
9394
.with_context(|| format!("Reading {path:?} to load it in cache"));
9495
let parsed = match file_contents {
9596
Ok(contents) => Ok(T::from_str_with_state(app_state, &contents).await?),

0 commit comments

Comments
 (0)