fix: Minor bugfix
This commit is contained in:
@@ -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]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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() {
|
||||||
|
|||||||
Reference in New Issue
Block a user