From 2d2ddc7b17dab183361b64ac4e66b945c984ab14 Mon Sep 17 00:00:00 2001 From: CDrummond Date: Sun, 15 Jun 2025 13:21:49 +0100 Subject: [PATCH] Don't crash if file has no tags. Closes #33 --- Cargo.lock | 2 +- Cargo.toml | 2 +- ChangeLog | 4 ++++ src/tags.rs | 8 +++++++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a42302..cbc0392 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -180,7 +180,7 @@ dependencies = [ [[package]] name = "bliss-analyser" -version = "0.4.0" +version = "0.4.1" dependencies = [ "anyhow", "argparse", diff --git a/Cargo.toml b/Cargo.toml index 845c59d..c511229 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bliss-analyser" -version = "0.4.0" +version = "0.4.1" authors = ["Craig Drummond "] edition = "2021" license = "GPL-3.0-only" diff --git a/ChangeLog b/ChangeLog index 3ae77c8..4d994ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +0.4.1 +----- +1. Don't crash if file has no tags. + 0.4.0 ----- 1. Add action to export results from DB to files. diff --git a/src/tags.rs b/src/tags.rs index d5b42c5..70c97ae 100644 --- a/src/tags.rs +++ b/src/tags.rs @@ -151,7 +151,13 @@ pub fn read(track: &String, read_analysis: bool) -> db::Metadata { if let Ok(file) = lofty::read_from_path(Path::new(track)) { let tag = match file.primary_tag() { Some(primary_tag) => primary_tag, - None => file.first_tag().expect("Error: No tags found!"), + None => { + if let Some(first_tag) = file.first_tag() { + first_tag + } else { + return meta; + } + } }; meta.title = tag.title().unwrap_or_default().to_string();