mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-07 01:56:45 +01:00
write to file!
This commit is contained in:
parent
0d1d4b6e9a
commit
bba8d39872
1 changed files with 3 additions and 1 deletions
|
|
@ -88,13 +88,15 @@ impl Perch {
|
||||||
}
|
}
|
||||||
/// Write all modified tags
|
/// Write all modified tags
|
||||||
pub(crate) fn save_all (&mut self) -> Usually<()> {
|
pub(crate) fn save_all (&mut self) -> Usually<()> {
|
||||||
|
use std::fs::File;
|
||||||
use lofty::{tag::TagExt, config::WriteOptions};
|
use lofty::{tag::TagExt, config::WriteOptions};
|
||||||
for entry in self.entries.iter_mut() {
|
for entry in self.entries.iter_mut() {
|
||||||
if let Metadata::Music {
|
if let Metadata::Music {
|
||||||
modified_tag: Some(modified_tag), ..
|
modified_tag: Some(modified_tag), ..
|
||||||
} = &mut *entry.info.write().unwrap() {
|
} = &mut *entry.info.write().unwrap() {
|
||||||
let tag = modified_tag.read().unwrap();
|
let tag = modified_tag.read().unwrap();
|
||||||
let mut file = std::fs::File::open(entry.path.as_path())?;
|
let path = entry.path.as_path();
|
||||||
|
let mut file = File::options().read(true).write(true).open(path)?;
|
||||||
tag.save_to(&mut file, WriteOptions::default())?;
|
tag.save_to(&mut file, WriteOptions::default())?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue