Repository navigation
Closed
Description
Reproducer
I tried this code:
pub fn save_standard_metadata(&self) -> anyhow::Result<()> {
let mut tagged_file = lofty::read_from_path(&self.source.path)?;
let tag = match tagged_file.primary_tag_mut() {
Some(primary_tag) => primary_tag,
None => {
if let Some(first_tag) = tagged_file.first_tag_mut() {
first_tag
} else {
let tag_type = tagged_file.primary_tag_type();
eprintln!("WARN: No tags found, creating a new tag of type `{tag_type:?}`");
tagged_file.insert_tag(Tag::new(tag_type));
tagged_file.primary_tag_mut().unwrap()
}
}
};
if let Some(title) = &self.md.title {
tag.set_title(title.clone());
}
if let Some(artist) = &self.md.artist {
tag.set_artist(artist.clone());
}
if let Some(remixer) = &self.md.remixer {
tag.insert_text(lofty::tag::ItemKey::Remixer, remixer.clone());
}
if let Some(label) = &self.md.label {
tag.insert_text(lofty::tag::ItemKey::Label, label.clone());
}
if let Some(album) = &self.md.album {
tag.set_album(album.clone());
}
if let Some(bpm) = &self.md.bpm {
tag.insert_text(lofty::tag::ItemKey::Bpm, bpm.to_string());
// Get rid of the integer key...
tag.remove_key(lofty::tag::ItemKey::IntegerBpm);
}
if let Some(rating) = self.md.rating {
tag.insert_text(lofty::tag::ItemKey::Popularimeter, rating.to_string());
}
if let Some(comment) = &self.md.comment {
tag.set_comment(comment.clone());
}
if let Some(genre) = &self.md.genre {
tag.set_genre(genre.clone());
}
if let Some(year) = &self.md.year {
tag.insert(TagItem::new(
lofty::tag::ItemKey::Year,
ItemValue::Text(format!("{}", *year)),
));
}
if let Some(color) = &self.md.color {
tag.insert_text(lofty::tag::ItemKey::Color, color.to_string());
}
tagged_file.save_to_path(&self.source.path, lofty::config::WriteOptions::default())?;
Ok(())
}Summary
This will corrupt my flac files:
flac -t *.flac
flac 1.5.0
Copyright (C) 2000-2009 Josh Coalson, 2011-2025 Xiph.Org Foundation
flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
welcome to redistribute it under certain conditions. Type `flac' for details.
01 - Insane Creatures - Fang Tooth (154 Bpm).flac: *** Got error code 0:FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC after processing 21315071 samples
01 - Insane Creatures - Fang Tooth (154 Bpm).flac: ERROR during decoding
state = FLAC__STREAM_DECODER_END_OF_STREAM
02 - Insane Creatures - Kodama´s Octopus (158 Bpm).flac: *** Got error code 0:FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC after processing 21133309 samples
02 - Insane Creatures - Kodama´s Octopus (158 Bpm).flac: ERROR during decoding
state = FLAC__STREAM_DECODER_END_OF_STREAM
03 - Insane Creatures & Senskrypt - Unveiling The Hydra´s Dream (156 Bpm).flac: ok
04 - Insane Creatures - Luna Negra (158 Bpm).flac: *** Got error code 0:FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC after processing 21088480 samples
04 - Insane Creatures - Luna Negra (158 Bpm).flac: ERROR during decoding
state = FLAC__STREAM_DECODER_END_OF_STREAM
05 - Insane Creatures & Leakowr - Synaptic Reef (160 Bpm).flac: ok
06 - Insane Creatures - Elementos (160 Bpm).flac: *** Got error code 0:FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC after processing 22523673 samples
06 - Insane Creatures - Elementos (160 Bpm).flac: ERROR during decoding
state = FLAC__STREAM_DECODER_END_OF_STREAM
07 - Insane Creatures - Complexities Of The Deep (162 Bpm).flac: ok
08 - Insane Creatures & Koorow - Subaquatic Reveries (162 Bpm).flac: ok
09 - Insane Creatures - The Dwellers Tangerine (164 Bpm).flac: *** Got error code 0:FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC after processing 18464768 samples
09 - Insane Creatures - The Dwellers Tangerine (164 Bpm).flac: ERROR while decoding data
state = FLAC__STREAM_DECODER_ABORTED
Expected behavior
No response
Assets
No response
Activity
Serial-ATA commentedon Apr 10, 2026
Can you email one of the files to
serial AT [domain on my profile]?abique commentedon Apr 10, 2026
Sent.
Serial-ATA commentedon Apr 10, 2026
Thanks! I'll take a look soon
abique commentedon Apr 10, 2026
Thank you very much :-)
Serial-ATA commentedon Apr 11, 2026
This was broken all the way back in #583, surprised it didn't come up earlier. Can you test #641 against the original files?
feat: lofty 0.21→0.25.4 — FLAC 元数据缩小写坏文件修复 + R128/ReleaseType 一等键
Bump lofty to 0.25.5 workspace-wide; add FLAC metadata-shrink regress…