in core/src/services/fs/backend.rs [617:645]
fn blocking_stat(&self, path: &str, _: OpStat) -> Result<RpStat> {
let p = self.root.join(path.trim_end_matches('/'));
let meta = std::fs::metadata(p).map_err(parse_io_error)?;
if self.enable_path_check && meta.is_dir() != path.ends_with('/') {
return Err(Error::new(
ErrorKind::NotFound,
"file mode is not match with its path",
));
}
let mode = if meta.is_dir() {
EntryMode::DIR
} else if meta.is_file() {
EntryMode::FILE
} else {
EntryMode::Unknown
};
let m = Metadata::new(mode)
.with_content_length(meta.len())
.with_last_modified(
meta.modified()
.map(DateTime::from)
.map_err(parse_io_error)?,
);
Ok(RpStat::new(m))
}