diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2025-01-26 14:59:14 -0800 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2025-01-26 14:59:14 -0800 |
commit | d7cb6607d1859a74a1565e007ace7c6894c7d6de (patch) | |
tree | b3261b28a3c71d0c2769fbd28834cd687feac0cf | |
parent | 9438bdf2b7c46d173f175874811c028c78d723a9 (diff) |
Add edit/reset option
-rw-r--r-- | src/lib.rs | 8 | ||||
-rw-r--r-- | src/main.rs | 7 |
2 files changed, 15 insertions, 0 deletions
@@ -147,10 +147,18 @@ impl MP32RSS { }) } + pub fn access(&self) -> &s3::Access { + &self.access + } + pub fn get_mut_entry(&mut self, filename: &str) -> Option<&mut Entry> { self.index.entries.get_mut(filename) } + pub fn insert_entry(&mut self, entry: Entry) { + self.index.entries.insert(entry.filename.clone(), entry); + } + pub async fn sync(&mut self) -> Result<(), Box<dyn Error>> { info!("Saving index file"); let new_etag = self diff --git a/src/main.rs b/src/main.rs index 4a89183..5c56c93 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,6 +68,9 @@ struct EditArgs { /// True if the entry should not be published. #[arg(long)] hidden: Option<bool>, + /// Reset the metadata to match the file. + #[arg(long)] + reset: bool, } #[derive(clap::Args, Debug)] @@ -110,6 +113,10 @@ async fn main() -> Result<(), Box<dyn Error>> { } async fn update_entry(feed: &mut MP32RSS, args: EditArgs) -> Result<(), Box<dyn Error>> { + if args.reset { + let new_entry = feed.access().fetch_entry(args.filename.clone()).await?; + feed.insert_entry(new_entry); + } if let Some(entry) = feed.get_mut_entry(&args.filename) { if let Some(v) = args.title { entry.title = Some(v); |