mirror of
https://github.com/CDrummond/bliss-analyser.git
synced 2025-04-07 20:50:04 +03:00
When saving anlysis results to a comment tag, remove any previous
results.
This commit is contained in:
parent
98b9cd61e0
commit
ac87ebb66c
14
src/tags.rs
14
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<ItemValue> = 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));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user