You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2025/01/13 04:56:52 UTC
(opendal) 01/01: feat(core): Add correctness check for read with if_xxx headers
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch add-correct-check
in repository https://gitbox.apache.org/repos/asf/opendal.git
commit d4e1dce0aba734733135661b7371eff2f87fc558
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Mon Jan 13 12:56:24 2025 +0800
feat(core): Add correctness check for read with if_xxx headers
Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
core/src/layers/correctness_check.rs | 58 +++++++++++++++++++++++++++++++++++-
1 file changed, 57 insertions(+), 1 deletion(-)
diff --git a/core/src/layers/correctness_check.rs b/core/src/layers/correctness_check.rs
index 61d0669a3..ceeb32674 100644
--- a/core/src/layers/correctness_check.rs
+++ b/core/src/layers/correctness_check.rs
@@ -56,7 +56,7 @@ pub(crate) fn new_unsupported_error(info: &AccessorInfo, op: Operation, args: &s
Error::new(
ErrorKind::Unsupported,
- format!("service {scheme} doesn't support operation {op} with args {args}"),
+ format!("The service {scheme} does not support the operation {op} with the arguments {args}. Please verify if the relevant flags have been enabled, or submit an issue if you believe this is incorrect."),
)
.with_operation(op)
}
@@ -102,6 +102,34 @@ impl<A: Access> LayeredAccess for CorrectnessAccessor<A> {
"version",
));
}
+ if !capability.read_with_if_match && args.if_match().is_some() {
+ return Err(new_unsupported_error(
+ self.info.as_ref(),
+ Operation::Read,
+ "if_match",
+ ));
+ }
+ if !capability.read_with_if_none_match && args.if_none_match().is_some() {
+ return Err(new_unsupported_error(
+ self.info.as_ref(),
+ Operation::Read,
+ "if_none_match",
+ ));
+ }
+ if !capability.read_with_if_modified_since && args.if_modified_since().is_some() {
+ return Err(new_unsupported_error(
+ self.info.as_ref(),
+ Operation::Read,
+ "if_modified_since",
+ ));
+ }
+ if !capability.read_with_if_unmodified_since && args.if_unmodified_since().is_some() {
+ return Err(new_unsupported_error(
+ self.info.as_ref(),
+ Operation::Read,
+ "if_unmodified_since",
+ ));
+ }
self.inner.read(path, args).await
}
@@ -146,6 +174,34 @@ impl<A: Access> LayeredAccess for CorrectnessAccessor<A> {
"version",
));
}
+ if !capability.stat_with_if_match && args.if_match().is_some() {
+ return Err(new_unsupported_error(
+ self.info.as_ref(),
+ Operation::Stat,
+ "if_match",
+ ));
+ }
+ if !capability.stat_with_if_none_match && args.if_none_match().is_some() {
+ return Err(new_unsupported_error(
+ self.info.as_ref(),
+ Operation::Stat,
+ "if_none_match",
+ ));
+ }
+ if !capability.stat_with_if_modified_since && args.if_modified_since().is_some() {
+ return Err(new_unsupported_error(
+ self.info.as_ref(),
+ Operation::Stat,
+ "if_modified_since",
+ ));
+ }
+ if !capability.stat_with_if_unmodified_since && args.if_unmodified_since().is_some() {
+ return Err(new_unsupported_error(
+ self.info.as_ref(),
+ Operation::Stat,
+ "if_unmodified_since",
+ ));
+ }
self.inner.stat(path, args).await
}