diff options
| author | lukeflo | 2025-05-24 18:12:43 +0200 |
|---|---|---|
| committer | lukeflo | 2025-05-24 18:12:43 +0200 |
| commit | d112312c3fcf79c679e2aa4a47a60b69f83cbce9 (patch) | |
| tree | 1a6982ab95e3bad9a6145fb1b0fa7275fb181736 /src | |
| parent | ee2d8c04c5fdce6e3384ecceee9a5250d8d586fe (diff) | |
| download | bibiman-d112312c3fcf79c679e2aa4a47a60b69f83cbce9.tar.gz bibiman-d112312c3fcf79c679e2aa4a47a60b69f83cbce9.zip | |
remove already assigned filepaths from pdf_files vec
Diffstat (limited to 'src')
| -rw-r--r-- | src/bibiman/bibisetup.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/bibiman/bibisetup.rs b/src/bibiman/bibisetup.rs index b968658..aa0640c 100644 --- a/src/bibiman/bibisetup.rs +++ b/src/bibiman/bibisetup.rs @@ -189,7 +189,7 @@ impl BibiSetup { bibliography: &Bibliography, cfg: &BibiConfig, ) -> Vec<BibiData> { - let pdf_files = if cfg.general.pdf_path.is_some() { + let mut pdf_files = if cfg.general.pdf_path.is_some() { collect_pdf_files(cfg.general.pdf_path.as_ref().unwrap()) } else { None @@ -208,7 +208,7 @@ impl BibiSetup { citekey: k.to_owned(), abstract_text: Self::get_abstract(k, bibliography), doi_url: Self::get_weblink(k, bibliography), - filepath: Self::get_filepath(k, bibliography, &pdf_files), + filepath: Self::get_filepath(k, bibliography, &mut pdf_files), subtitle: Self::get_subtitle(k, bibliography), }) .collect() @@ -343,7 +343,7 @@ impl BibiSetup { pub fn get_filepath( citekey: &str, biblio: &Bibliography, - pdf_files: &Option<Vec<PathBuf>>, + pdf_files: &mut Option<Vec<PathBuf>>, ) -> Option<OsString> { if biblio.get(citekey).unwrap().file().is_ok() { Some(biblio.get(citekey).unwrap().file().unwrap().trim().into()) @@ -369,7 +369,10 @@ impl BibiSetup { } } - fn merge_filepath_or_none(citekey: &str, pdf_files: &Option<Vec<PathBuf>>) -> Option<OsString> { + fn merge_filepath_or_none( + citekey: &str, + pdf_files: &mut Option<Vec<PathBuf>>, + ) -> Option<OsString> { // Oder n Loop??? let pdf_file = { let mut idx = 0; @@ -395,7 +398,9 @@ impl BibiSetup { .unwrap() == citekey { - break Some(cur_entry.to_owned().into_os_string()); + let path = cur_entry.to_owned().into_os_string(); + pdf_files.as_mut().unwrap().swap_remove(idx); + break Some(path); } else { idx += 1 } |
