Skip to content

Commit

Permalink
fix: Don't call Storage::delete_objects with empty objects array (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
chubei authored Sep 8, 2023
1 parent 96b72c0 commit 0f79efe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dozer-log/src/replication/persist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 4 additions & 0 deletions dozer-log/src/storage/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ impl Storage for LocalStorage {
}

async fn delete_objects(&self, keys: Vec<String>) -> 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)
Expand Down
2 changes: 2 additions & 0 deletions dozer-log/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0f79efe

Please sign in to comment.