diff --git a/dozer-log/src/replication/persist.rs b/dozer-log/src/replication/persist.rs index 582bbc7a03..75b5b00d71 100644 --- a/dozer-log/src/replication/persist.rs +++ b/dozer-log/src/replication/persist.rs @@ -68,7 +68,9 @@ pub async fn load_persisted_log_entries( } // Remove extra entries. These are persisted in the middle of a checkpointing, but the checkpointing didn't finish. - storage.delete_objects(to_remove).await?; + if !to_remove.is_empty() { + storage.delete_objects(to_remove).await?; + } // Check invariants. if let Some(first) = result.first() { diff --git a/dozer-log/src/storage/local.rs b/dozer-log/src/storage/local.rs index 251361ee62..58f5a8391e 100644 --- a/dozer-log/src/storage/local.rs +++ b/dozer-log/src/storage/local.rs @@ -167,6 +167,10 @@ impl Storage for LocalStorage { } async fn delete_objects(&self, keys: Vec) -> Result<(), Error> { + if keys.is_empty() { + return Err(Error::EmptyDeleteObjectsRequest); + } + for key in keys { let path = self.get_path(&key).await?; tokio::fs::remove_file(&path) diff --git a/dozer-log/src/storage/mod.rs b/dozer-log/src/storage/mod.rs index dbe3ee3107..529a077615 100644 --- a/dozer-log/src/storage/mod.rs +++ b/dozer-log/src/storage/mod.rs @@ -111,6 +111,8 @@ pub enum Error { NonUtf8Path(PathBuf), #[error("upload not found: key {key}, upload id {upload_id}")] UploadNotFound { key: String, upload_id: String }, + #[error("empty delete objects request")] + EmptyDeleteObjectsRequest, } use dyn_clone::DynClone;