fix: Minor bugfix

This commit is contained in:
2025-09-09 22:50:42 +03:00
parent 4a7ed0974c
commit ec8cc12bf8
2 changed files with 5 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ pub fn parse(path: &PathBuf) -> Result<Vec<Book>, String> {
let mut author = Author::new(); let mut author = Author::new();
author.first_name = path.extension().unwrap().to_string_lossy().to_string(); author.first_name = path.extension().unwrap().to_string_lossy().to_string();
book.author.push(author); book.author.push(author);
book.source = path.into();
return Ok(vec![ book]); return Ok(vec![ book]);
} }

View File

@@ -70,7 +70,10 @@ impl Books {
pub fn add_books_from_path(&mut self) { pub fn add_books_from_path(&mut self) {
let books = fs::Loader::new(PathBuf::from(&self.root)) let books = fs::Loader::new(PathBuf::from(&self.root))
.into_iter() .into_iter()
.map(|mut book| {book.source = book.source.strip_prefix(&self.root).unwrap().into(); book}) .map(|mut book| {match book.source.strip_prefix(&self.root) {
Ok(path) => book.source = path.to_path_buf(),
Err(err) => eprintln!("strip source prefix: {}", err)
}; book})
.collect(); .collect();
match self.repo.lock() { match self.repo.lock() {