aboutsummaryrefslogtreecommitdiff
path: root/src/model/bucket_alias_table.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-01-03 18:32:15 +0100
committerAlex Auvolat <alex@adnab.me>2022-01-04 12:52:47 +0100
commit1bcd6fabbdc0cd9dee88ba28daecb5339f2c13ec (patch)
tree6a812200ac8e049c21702ae1623a516d6e274f28 /src/model/bucket_alias_table.rs
parentba7f268b990cd17c5d20bf9e0eb6ff77d30fe845 (diff)
downloadgarage-1bcd6fabbdc0cd9dee88ba28daecb5339f2c13ec.tar.gz
garage-1bcd6fabbdc0cd9dee88ba28daecb5339f2c13ec.zip
New buckets for 0.6.0: small changes
- Fix bucket delete - fix merge of bucket creation date - Replace deletable with option in aliases Rationale: if two aliases point to conflicting bucket, resolving by making an arbitrary choice risks making data accessible when it shouldn't be. We'd rather resolve to deleting the alias until someone puts it back.
Diffstat (limited to 'src/model/bucket_alias_table.rs')
-rw-r--r--src/model/bucket_alias_table.rs17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/model/bucket_alias_table.rs b/src/model/bucket_alias_table.rs
index 45807178..fce03d04 100644
--- a/src/model/bucket_alias_table.rs
+++ b/src/model/bucket_alias_table.rs
@@ -10,32 +10,23 @@ use garage_table::*;
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
pub struct BucketAlias {
name: String,
- pub state: crdt::Lww<crdt::Deletable<AliasParams>>,
-}
-
-#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Debug, Serialize, Deserialize)]
-pub struct AliasParams {
- pub bucket_id: Uuid,
-}
-
-impl AutoCrdt for AliasParams {
- const WARN_IF_DIFFERENT: bool = true;
+ pub state: crdt::Lww<Option<Uuid>>,
}
impl BucketAlias {
- pub fn new(name: String, ts: u64, bucket_id: Uuid) -> Option<Self> {
+ pub fn new(name: String, ts: u64, bucket_id: Option<Uuid>) -> Option<Self> {
if !is_valid_bucket_name(&name) {
None
} else {
Some(BucketAlias {
name,
- state: crdt::Lww::raw(ts, crdt::Deletable::present(AliasParams { bucket_id })),
+ state: crdt::Lww::raw(ts, bucket_id),
})
}
}
pub fn is_deleted(&self) -> bool {
- self.state.get().is_deleted()
+ self.state.get().is_none()
}
pub fn name(&self) -> &str {
&self.name