Skip to content

Support for conditional deletes#610

Open
pdeva wants to merge 3 commits intoapache:mainfrom
pdeva:pdeva/cond-delete
Open

Support for conditional deletes#610
pdeva wants to merge 3 commits intoapache:mainfrom
pdeva:pdeva/cond-delete

Conversation

@pdeva
Copy link
Copy Markdown
Contributor

@pdeva pdeva commented Jan 16, 2026

Which issue does this PR close?

Closes #298 .

Supersedes the now stale PR #427

@pdeva pdeva mentioned this pull request Jan 16, 2026

async fn delete_opts(&self, location: &Path, opts: DeleteOptions) -> Result<()> {
let _ = (location, opts);
Err(crate::Error::NotImplemented {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be strictly worse than the default impl?

@tustvold
Copy link
Copy Markdown
Contributor

Tagging @crepererum as this sort of overlaps with #549

@crepererum
Copy link
Copy Markdown
Contributor

I should have considered this in #549. Reading the Azure docs though, I think etag matching is also supported by the bulk request variant. So I think we could design an API like this:

pub struct DeleteLocation {
    pub path: Path,
    pub if_match: Option<String>,
}

#[derive(Debug, Clone, Default)]
pub struct DeleteOptions {
    pub extensions: Extensions,
}

trait ObjectStore {
    fn delete_stream_opts(
        &self,
        locations: BoxStream<'static, Result<DeleteLocation>>,
        opts: DeleteOptions,
    ) -> BoxStream<'static, Result<Path>>;
}

// move `delete_stream` to `ObjectStoreExt`

i.e. have the extensions ONCE but have per-location matchers.

@tustvold
Copy link
Copy Markdown
Contributor

Coming back to this, I think having a separate delete_opts makes sense and has symmetry with get_opts and get_ranges, where we have a unary method with a full set of functionality, and a more limited batch version.

Comment on lines +1933 to +1945
/// Delete will succeed if the `ObjectMeta::e_tag` matches
/// otherwise returning [`Error::Precondition`]
///
/// See <https://datatracker.ietf.org/doc/html/rfc9110#name-if-match>
///
/// Examples:
///
/// ```text
/// If-Match: "xyzzy"
/// If-Match: "xyzzy", "r2d2xxxx", "c3piozzzz"
/// If-Match: *
/// ```
pub if_match: Option<String>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will need to use something similar to UpdateVersion found in PutMode as some stores don't support If-Match on mutating methods

.idempotent(true);

if let Some(if_match) = &opts.if_match {
builder = builder.header(&HeaderName::from_static("if-match"), if_match);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested this?

The docs would suggest If-Match is only supported on GET and HEAD

https://docs.cloud.google.com/storage/docs/xml-api/reference-headers#ifmatch

This is why PutMode has UpdateVersion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add support for conditional deletes

3 participants