From f85458c8ad0ff7d7f79081a1c0a3a80b703c9f53 Mon Sep 17 00:00:00 2001 From: graelo Date: Thu, 11 Aug 2022 00:10:15 +0200 Subject: [PATCH] fix(save): refresh the catalog before compacting --- src/main.rs | 3 +++ src/management/catalog.rs | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/main.rs b/src/main.rs index 827e226..45bbb70 100755 --- a/src/main.rs +++ b/src/main.rs @@ -51,6 +51,9 @@ async fn run(config: Config) { // In practice this should never fail: write to the catalog already ensures // the catalog's dirpath is writable. catalog + .refresh() + .await + .expect("Success saving but could not refresh") .compact() .await .expect("Success saving but could not compact"); diff --git a/src/management/catalog.rs b/src/management/catalog.rs index 9192033..ba50e39 100644 --- a/src/management/catalog.rs +++ b/src/management/catalog.rs @@ -93,6 +93,16 @@ impl Catalog { Ok(catalog) } + /// Update the catalog's list of backups with current content of `dirpath`. + pub async fn refresh(self) -> Result { + let backups = Self::read_files(self.dirpath.as_path()).await?; + Ok(Catalog { + dirpath: self.dirpath, + strategy: self.strategy, + backups, + }) + } + /// Update the catalog's list of backups with current content of `dirpath`. pub async fn refresh_mut(&mut self) -> Result<()> { self.backups = Self::read_files(self.dirpath.as_path()).await?;