From ce357b9a123369f953be3fbcb22e87d3304e2e4b Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Wed, 24 Nov 2021 10:00:07 +0100 Subject: Add ListMultipartUploads + Refactor ListObjects --- src/model/object_table.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/model') diff --git a/src/model/object_table.rs b/src/model/object_table.rs index 0c6c3a6d..da53878e 100644 --- a/src/model/object_table.rs +++ b/src/model/object_table.rs @@ -218,13 +218,19 @@ pub struct ObjectTable { pub version_table: Arc>, } +#[derive(Clone, Copy, Debug, Serialize, Deserialize)] +pub enum ObjectFilter { + IsData, + IsUploading, +} + impl TableSchema for ObjectTable { const TABLE_NAME: &'static str = "object"; type P = Uuid; type S = String; type E = Object; - type Filter = DeletedFilter; + type Filter = ObjectFilter; fn updated(&self, old: Option, new: Option) { let version_table = self.version_table.clone(); @@ -254,8 +260,10 @@ impl TableSchema for ObjectTable { } fn matches_filter(entry: &Self::E, filter: &Self::Filter) -> bool { - let deleted = !entry.versions.iter().any(|v| v.is_data()); - filter.apply(deleted) + match filter { + ObjectFilter::IsData => entry.versions.iter().any(|v| v.is_data()), + ObjectFilter::IsUploading => entry.versions.iter().any(|v| v.is_uploading()), + } } fn try_migrate(bytes: &[u8]) -> Option { -- cgit v1.2.3