diff --git a/ChangeLog b/ChangeLog index 4030763..4979a20 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,8 @@ defualt. Pass "--features=libav" to cargo to build against ffmpeg libraries. 4. Add ability to specify LMS JSONRPC port. +5. If new files analysed and 'ignore' file exists then update DB's 'ignore' + flags. 0.2.3 ----- diff --git a/src/analyse.rs b/src/analyse.rs index 7b7c199..37b84e6 100644 --- a/src/analyse.rs +++ b/src/analyse.rs @@ -376,7 +376,7 @@ pub fn analyse_new_cue_tracks(db:&db::Db, mpath: &PathBuf, cue_tracks:Vec, dry_run: bool, keep_old: bool, max_num_files: usize, max_threads: usize) { +pub fn analyse_files(db_path: &str, mpaths: &Vec, dry_run: bool, keep_old: bool, max_num_files: usize, max_threads: usize, ignore_path: &PathBuf) { let mut db = db::Db::new(&String::from(db_path)); db.init(); @@ -385,6 +385,7 @@ pub fn analyse_files(db_path: &str, mpaths: &Vec, dry_run: bool, keep_o db.remove_old(mpaths, dry_run); } + let mut changes_made = false; for path in mpaths { let mpath = path.clone(); let cur = path.clone(); @@ -417,7 +418,7 @@ pub fn analyse_files(db_path: &str, mpaths: &Vec, dry_run: bool, keep_o } else { if !track_paths.is_empty() { match analyse_new_files(&db, &mpath, track_paths, max_threads) { - Ok(_) => { } + Ok(_) => { changes_made = true; } Err(e) => { log::error!("Analysis returned error: {}", e); } } } else { @@ -427,7 +428,7 @@ pub fn analyse_files(db_path: &str, mpaths: &Vec, dry_run: bool, keep_o #[cfg(not(feature = "libav"))] if !cue_tracks.is_empty() { match analyse_new_cue_tracks(&db, &mpath, cue_tracks) { - Ok(_) => { }, + Ok(_) => { changes_made = true; }, Err(e) => { log::error!("Cue analysis returned error: {}", e); } } } @@ -435,6 +436,10 @@ pub fn analyse_files(db_path: &str, mpaths: &Vec, dry_run: bool, keep_o } db.close(); + if changes_made && ignore_path.exists() && ignore_path.is_file() { + log::info!("Updating 'ignore' flags"); + update_ignore(&db_path, &ignore_path); + } } pub fn read_tags(db_path: &str, mpaths: &Vec) { diff --git a/src/main.rs b/src/main.rs index f456747..c40a258 100644 --- a/src/main.rs +++ b/src/main.rs @@ -199,7 +199,8 @@ fn main() { } analyse::update_ignore(&db_path, &ignore_path); } else { - analyse::analyse_files(&db_path, &music_paths, dry_run, keep_old, max_num_files, max_threads); + let ignore_path = PathBuf::from(&ignore_file); + analyse::analyse_files(&db_path, &music_paths, dry_run, keep_old, max_num_files, max_threads, &ignore_path); } } }