Skip to content

Commit

Permalink
return unsupport for read/stat/delete when versioning is not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorgan committed Sep 26, 2024
1 parent d479ac3 commit 596946f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion core/src/services/s3/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,13 @@ impl Access for S3Backend {
}

async fn stat(&self, path: &str, args: OpStat) -> Result<RpStat> {
if args.version().is_some() && !self.core.enable_versioning {
return Err(Error::new(
ErrorKind::Unsupported,
"the bucket doesn't enable versioning, cannot stat with version",
));
}

let resp = self.core.s3_head_object(path, args).await?;

let status = resp.status();
Expand Down Expand Up @@ -994,6 +1001,13 @@ impl Access for S3Backend {
}

async fn read(&self, path: &str, args: OpRead) -> Result<(RpRead, Self::Reader)> {
if args.version().is_some() && !self.core.enable_versioning {
return Err(Error::new(
ErrorKind::Unsupported,
"the bucket doesn't enable versioning, cannot read with version",
));
}

let resp = self.core.s3_get_object(path, args.range(), &args).await?;

let status = resp.status();
Expand Down Expand Up @@ -1025,6 +1039,13 @@ impl Access for S3Backend {
return Ok(RpDelete::default());
}

if args.version().is_some() && !self.core.enable_versioning {
return Err(Error::new(
ErrorKind::Unsupported,
"the bucket doesn't enable versioning, cannot delete with version",
));
}

let resp = self.core.s3_delete_object(path, &args).await?;

let status = resp.status();
Expand All @@ -1043,7 +1064,7 @@ impl Access for S3Backend {
if args.version() && !self.core.enable_versioning {
return Err(Error::new(
ErrorKind::Unsupported,
"the bucket doesn't enable versioning",
"the bucket doesn't enable versioning, cannot list with version",
));
}

Expand Down

0 comments on commit 596946f

Please sign in to comment.