Import and update the file service application and orizentic #72
|
@ -116,18 +116,19 @@ impl Store {
|
||||||
|
|
||||||
pub fn list_files(&self) -> Result<HashSet<FileId>, ReadFileError> {
|
pub fn list_files(&self) -> Result<HashSet<FileId>, ReadFileError> {
|
||||||
let paths = std::fs::read_dir(&self.files_root)?;
|
let paths = std::fs::read_dir(&self.files_root)?;
|
||||||
Ok(paths
|
let info_files = paths
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|path| {
|
.filter_map(|path| {
|
||||||
FileId::from(
|
let path_ = path.unwrap().path();
|
||||||
path.unwrap()
|
if path_.extension().and_then(|s| s.to_str()) == Some("json") {
|
||||||
.path()
|
let stem = path_.file_stem().and_then(|s| s.to_str()).unwrap();
|
||||||
.file_stem()
|
Some(FileId::from(FileId::from(stem)))
|
||||||
.and_then(|s| s.to_str())
|
} else {
|
||||||
.unwrap(),
|
None
|
||||||
)
|
}
|
||||||
})
|
})
|
||||||
.collect::<HashSet<FileId>>())
|
.collect::<HashSet<FileId>>();
|
||||||
|
Ok(info_files)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_file(
|
pub fn add_file(
|
||||||
|
@ -237,6 +238,7 @@ mod test {
|
||||||
|
|
||||||
println!("ids: {:?}", ids);
|
println!("ids: {:?}", ids);
|
||||||
assert_eq!(ids.len(), 1);
|
assert_eq!(ids.len(), 1);
|
||||||
|
assert!(ids.contains(&id));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue