Import and update the file service application and orizentic #72

Merged
savanni merged 36 commits from file-service into main 2023-10-03 23:50:54 +00:00
1 changed files with 12 additions and 10 deletions
Showing only changes of commit 94aa67a156 - Show all commits

View File

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