Skip to content

Commit d1e2c76

Browse files
committed
add Disabled variant to S3ConditionalPut
1 parent b3e8ffa commit d1e2c76

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

.github/workflows/object_store.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,15 @@ jobs:
165165
166166
- name: Run object_store tests
167167
run: cargo test --features=aws,azure,gcp,http
168+
env:
169+
AWS_CONDITIONAL_PUT: disabled
168170

169171
- name: Run object_store tests (AWS native conditional put)
170172
run: cargo test --features=aws
171173
env:
172174
AWS_CONDITIONAL_PUT: etag
173175
AWS_COPY_IF_NOT_EXISTS: multipart
174-
176+
175177
- name: GCS Output
176178
if: ${{ !cancelled() }}
177179
run: docker logs $GCS_CONTAINER

object_store/src/aws/builder.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,8 @@ impl AmazonS3Builder {
823823
self
824824
}
825825

826-
/// Configure how to provide conditional put operations
826+
/// Configure how to provide conditional put operations.
827+
/// if not set, the default value will be `S3ConditionalPut::ETagMatch`
827828
pub fn with_conditional_put(mut self, config: S3ConditionalPut) -> Self {
828829
self.conditional_put = config.into();
829830
self

object_store/src/aws/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ impl ObjectStore for AmazonS3 {
169169

170170
match (opts.mode, &self.client.config.conditional_put) {
171171
(PutMode::Overwrite, _) => request.idempotent(true).do_put().await,
172+
(PutMode::Create, S3ConditionalPut::Disabled) => Err(Error::NotImplemented),
172173
(PutMode::Create, S3ConditionalPut::ETagMatch) => {
173174
match request.header(&IF_NONE_MATCH, "*").do_put().await {
174175
// Technically If-None-Match should return NotModified but some stores,
@@ -220,6 +221,7 @@ impl ObjectStore for AmazonS3 {
220221
})
221222
.await
222223
}
224+
S3ConditionalPut::Disabled => Err(Error::NotImplemented),
223225
}
224226
}
225227
}
@@ -560,6 +562,7 @@ mod tests {
560562
let integration = config.build().unwrap();
561563
let config = &integration.client.config;
562564
let test_not_exists = config.copy_if_not_exists.is_some();
565+
let test_conditional_put = config.conditional_put != S3ConditionalPut::Disabled;
563566

564567
put_get_delete_list(&integration).await;
565568
get_opts(&integration).await;
@@ -592,7 +595,9 @@ mod tests {
592595
if test_not_exists {
593596
copy_if_not_exists(&integration).await;
594597
}
595-
put_opts(&integration, true).await;
598+
if test_conditional_put {
599+
put_opts(&integration, true).await;
600+
}
596601

597602
// run integration test with unsigned payload enabled
598603
let builder = AmazonS3Builder::from_env().with_unsigned_payload(true);

object_store/src/aws/precondition.rs

+5
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,17 @@ pub enum S3ConditionalPut {
148148
///
149149
/// This will use the same region, credentials and endpoint as configured for S3
150150
Dynamo(DynamoCommit),
151+
152+
/// Disable `conditional put`
153+
Disabled,
151154
}
152155

153156
impl std::fmt::Display for S3ConditionalPut {
154157
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
155158
match self {
156159
Self::ETagMatch => write!(f, "etag"),
157160
Self::Dynamo(lock) => write!(f, "dynamo: {}", lock.table_name()),
161+
Self::Disabled => write!(f, "disabled"),
158162
}
159163
}
160164
}
@@ -163,6 +167,7 @@ impl S3ConditionalPut {
163167
fn from_str(s: &str) -> Option<Self> {
164168
match s.trim() {
165169
"etag" => Some(Self::ETagMatch),
170+
"disabled" => Some(Self::Disabled),
166171
trimmed => match trimmed.split_once(':')? {
167172
("dynamo", s) => Some(Self::Dynamo(DynamoCommit::from_str(s)?)),
168173
_ => None,

0 commit comments

Comments
 (0)