From ec8cc12bf82ae83db780d8694afd7c738728ccd8 Mon Sep 17 00:00:00 2001 From: derfenix Date: Tue, 9 Sep 2025 22:50:42 +0300 Subject: [PATCH] fix: Minor bugfix --- src/application/parsers/rs.rs | 1 + src/application/services/books.rs | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/application/parsers/rs.rs b/src/application/parsers/rs.rs index 8735498..7cd11c3 100644 --- a/src/application/parsers/rs.rs +++ b/src/application/parsers/rs.rs @@ -10,6 +10,7 @@ pub fn parse(path: &PathBuf) -> Result, String> { let mut author = Author::new(); author.first_name = path.extension().unwrap().to_string_lossy().to_string(); book.author.push(author); + book.source = path.into(); return Ok(vec![ book]); } diff --git a/src/application/services/books.rs b/src/application/services/books.rs index 3805832..36e8235 100644 --- a/src/application/services/books.rs +++ b/src/application/services/books.rs @@ -70,7 +70,10 @@ impl Books { pub fn add_books_from_path(&mut self) { 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}) + .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(); match self.repo.lock() {