You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TagType::remove_from_path always fails: file is opened read-only (0.25.4) #750
TagType::remove_from_path (and therefore TagExt::remove_from_path) always fails in 0.25.4 with failed to write to file, caused by Bad file descriptor (os error 9).
remove_from_path builds the file via VerifiedFile::new_from_path, which uses Probe::open. That opens the file with File::open, so it's read-only. do_remove then tries to write to it.
TagExt::save_to_path isn't affected because it opens the file with OpenOptions::new().read(true).write(true) itself.
Reproducer
use lofty::config::WriteOptions;use lofty::id3::v2::Id3v2Tag;use lofty::prelude::{Accessor,TagExt};use lofty::tag::TagType;fnmain(){// Any MP3 filelet path = std::env::temp_dir().join("lofty-remove-repro.mp3");
std::fs::copy(std::env::args().nth(1).unwrap(),&path).unwrap();letmut tag = Id3v2Tag::new();
tag.set_title("Title".to_string());
tag.save_to_path(&path,WriteOptions::default()).unwrap();let result = TagType::Id3v2.remove_from_path(&path,WriteOptions::default());match result {Ok(()) => println!("ok"),Err(e) => {println!("{e}");letmut source = std::error::Error::source(&e);whileletSome(cause) = source {println!("caused by: {cause}");
source = cause.source();}}}}
Output:
failed to write to file
caused by: Bad file descriptor (os error 9)
Expected behavior
The tag is removed, as in 0.24.
Workaround
Open the file read-write yourself and use remove_from:
Activity