aboutsummaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2021-11-24 10:00:07 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-01-12 17:07:40 +0100
commitce357b9a123369f953be3fbcb22e87d3304e2e4b (patch)
tree29357956ccc86becf0c62ee07fbbb1908efa34d2 /src/model
parent9cb2e9e57ce1aab23d8c3b2aaa7581c8e8b78253 (diff)
downloadgarage-ce357b9a123369f953be3fbcb22e87d3304e2e4b.tar.gz
garage-ce357b9a123369f953be3fbcb22e87d3304e2e4b.zip
Add ListMultipartUploads + Refactor ListObjects
Diffstat (limited to 'src/model')
-rw-r--r--src/model/object_table.rs14
1 files changed, 11 insertions, 3 deletions
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<Table<VersionTable, TableShardedReplication>>,
}
+#[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<Self::E>, new: Option<Self::E>) {
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<Self::E> {