From fa87a7e135d5f0e5cfb01f2c65babc8229d5c358 Mon Sep 17 00:00:00 2001 From: CDrummond Date: Sat, 28 May 2022 17:24:09 +0100 Subject: [PATCH] Fix checking if CUE already analysed. Issue #2 --- Cargo.lock | 2 +- ChangeLog | 1 + src/analyse.rs | 17 +++++++++++------ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ba6bbf7..7b32208 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "bliss-analyser" -version = "0.2.0" +version = "0.2.1" dependencies = [ "anyhow", "argparse", diff --git a/ChangeLog b/ChangeLog index 182128b..8c25bdf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 0.2.1 ----- 1. Update version of tag reader library. +2. Fix checking if CUE already analysed. 0.2.0 ----- diff --git a/src/analyse.rs b/src/analyse.rs index b64361d..e4b2686 100644 --- a/src/analyse.rs +++ b/src/analyse.rs @@ -58,14 +58,19 @@ fn check_dir_entry(db: &mut db::Db, mpath: &Path, entry: DirEntry, track_paths: cue_file.set_extension("cue"); if cue_file.exists() { // For cue files, check if first track is in DB - let mut track_path = pb.clone(); + let mut cue_track_path = pb.clone(); let ext = pb.extension().unwrap().to_string_lossy(); - track_path.set_extension(format!("{}{}1", ext, db::CUE_MARKER)); - let db_track = String::from(track_path.to_string_lossy()); - if let Ok(id) = db.get_rowid(&db_track) { - if id<=0 { - track_paths.push(String::from(cue_file.to_string_lossy())); + cue_track_path.set_extension(format!("{}{}1", ext, db::CUE_MARKER)); + match cue_track_path.strip_prefix(mpath) { + Ok(cue_track_stripped) => { + let cue_track_sname = String::from(cue_track_stripped.to_string_lossy()); + if let Ok(id) = db.get_rowid(&cue_track_sname) { + if id<=0 { + track_paths.push(String::from(cue_file.to_string_lossy())); + } + } } + Err(_) => { } } } else { if let Ok(id) = db.get_rowid(&sname) {