MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / read_dir_sync

Function read_dir_sync

nodedb/src/control/cold_tier.rs:207–221  ·  view source on GitHub ↗

Read a directory on a blocking thread, returning paths of all regular files.

(dir: &std::path::Path)

Source from the content-addressed store, hash-verified

205
206/// Read a directory on a blocking thread, returning paths of all regular files.
207async fn read_dir_sync(dir: &std::path::Path) -> std::io::Result<Vec<PathBuf>> {
208 let dir = dir.to_path_buf();
209 tokio::task::spawn_blocking(move || {
210 let mut result = Vec::new();
211 for entry in std::fs::read_dir(&dir)? {
212 let entry = entry?;
213 if entry.metadata()?.is_file() {
214 result.push(entry.path());
215 }
216 }
217 Ok(result)
218 })
219 .await
220 .map_err(|e| std::io::Error::other(format!("spawn_blocking join: {e}")))?
221}
222
223/// Return the elapsed time since a file was last modified, or `None` on any error.
224fn file_age(path: &std::path::Path, now: SystemTime) -> Option<Duration> {

Callers 1

run_tier_cycle_atFunction · 0.85

Calls 2

pushMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected