Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(storage): treat localfs read ENOENT as NotFound (#3935)

baojun-zhang8ef840da95df
diff --git a/crates/ragfs/src/plugins/localfs/mod.rs b/crates/ragfs/src/plugins/localfs/mod.rs
index 426cc6a57..6a3ddf27c 100644
--- a/crates/ragfs/src/plugins/localfs/mod.rs
+++ b/crates/ragfs/src/plugins/localfs/mod.rs
@@ -274,6 +274,14 @@ impl LocalFileSystem {
Error::plugin(format!("failed to lock for {operation}: {error}"))
}
+ /// Map local file failures into stable filesystem error categories.
+ fn map_error(path: &str, error: std::io::Error) -> Error {
+ if error.kind() == std::io::ErrorKind::NotFound {
+ return Error::NotFound(path.to_string());
+ }
+ Error::plugin(format!("failed to read file: {}", error))
+ }
+
/// Run blocking local filesystem work on a dedicated thread.
async fn run_blocking_fs<T, F>(job: F) -> Result<T>
where
@@ -956,8 +964,7 @@ impl FileSystem for LocalFileSystem {
}
// Read file
- let data = fs::read(&local_path)
- .map_err(|e| Error::plugin(format!("failed to read file: {}", e)))?;
+ let data = fs::read(&local_path).map_err(|e| Self::map_error(path, e))?;
// Apply offset and size
let file_size = data.len() as u64;