feat: Save book file path, refactoring

Close #1
This commit is contained in:
2025-09-09 21:16:14 +03:00
parent 18fa38120b
commit 00dc0e39b9
9 changed files with 85 additions and 195 deletions

View File

@@ -68,13 +68,14 @@ impl Books {
}
pub fn add_books_from_path(&mut self) {
let iter = fs::Loader::new(PathBuf::from(&self.root));
let books = fs::Loader::new(PathBuf::from(&self.root))
.into_iter()
.map(|mut book| {book.source = book.source.strip_prefix(&self.root).unwrap().into(); book})
.collect();
match self.repo.lock() {
Ok(mut repo) => {
for book in iter {
repo.add(book);
}
repo.bulk_add(books);
}
Err(err) => eprintln!("{}", err),
}