merge versioning, fix bug todo

This commit is contained in:
weisd
2024-11-02 00:21:10 +08:00
parent 28dc7379a6
commit 09ea11c13d
65 changed files with 5187 additions and 1966 deletions
+54
View File
@@ -0,0 +1,54 @@
use s3s::dto::{BucketVersioningStatus, VersioningConfiguration};
pub trait VersioningApi {
fn enabled(&self) -> bool;
fn prefix_enabled(&self, prefix: &str) -> bool;
fn prefix_suspended(&self, prefix: &str) -> bool;
}
impl VersioningApi for VersioningConfiguration {
fn enabled(&self) -> bool {
self.status
.as_ref()
.is_some_and(|v| v.as_str() == BucketVersioningStatus::ENABLED)
}
fn prefix_enabled(&self, prefix: &str) -> bool {
if !self
.status
.as_ref()
.is_some_and(|v| v.as_str() == BucketVersioningStatus::ENABLED)
{
return false;
}
if prefix.is_empty() {
return true;
}
// TODO: ExcludeFolders
true
}
fn prefix_suspended(&self, prefix: &str) -> bool {
if self
.status
.as_ref()
.is_some_and(|v| v.as_str() == BucketVersioningStatus::SUSPENDED)
{
return true;
}
if let Some(status) = self.status.as_ref() {
if status.as_str() == BucketVersioningStatus::ENABLED {
if prefix.is_empty() {
return false;
}
// TODO: ExcludeFolders
}
}
false
}
}