From ac87ebb66cdbb50cfc847afa19f3f172404e112d Mon Sep 17 00:00:00 2001 From: CDrummond Date: Wed, 5 Mar 2025 17:40:25 +0000 Subject: [PATCH] When saving anlysis results to a comment tag, remove any previous results. --- src/tags.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/tags.rs b/src/tags.rs index 6261508..5c5c11e 100644 --- a/src/tags.rs +++ b/src/tags.rs @@ -40,6 +40,20 @@ pub fn write_analysis(track: &String, analysis: &Analysis) { }, }; + // Remove any existing analysis result tag + let entries = tag.get_strings(&ANALYSIS_TAG); + let mut keep: Vec = Vec::new(); + for entry in entries { + if !entry.starts_with(ANALYSIS_TAG_START) { + keep.push(ItemValue::Text(entry.to_string())); + } + } + tag.remove_key(&ANALYSIS_TAG); + for k in keep { + tag.push(TagItem::new(ANALYSIS_TAG, k)); + } + + // Store analysis results tag.push(TagItem::new(ANALYSIS_TAG, ItemValue::Text(value))); let _ = tag.save_to_path(Path::new(track)); }