aboutsummaryrefslogtreecommitdiff
path: root/src/admin_rpc.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-04-23 18:16:33 +0000
committerAlex Auvolat <alex@adnab.me>2020-04-23 18:16:52 +0000
commit44a1089d9569b442c098c2ceebb3f691816e52d2 (patch)
tree58c5ebf9965e47a94bddff34a42636c6c30d1758 /src/admin_rpc.rs
parentc9c6b0dbd41e20d19b91c6615c46da6f45925bca (diff)
downloadgarage-44a1089d9569b442c098c2ceebb3f691816e52d2.tar.gz
garage-44a1089d9569b442c098c2ceebb3f691816e52d2.zip
Make table objects slightly more fool-proof; add key table
Diffstat (limited to 'src/admin_rpc.rs')
-rw-r--r--src/admin_rpc.rs35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/admin_rpc.rs b/src/admin_rpc.rs
index fe59f92e..17ef5072 100644
--- a/src/admin_rpc.rs
+++ b/src/admin_rpc.rs
@@ -100,12 +100,7 @@ impl AdminRpcHandler {
};
self.garage
.bucket_table
- .insert(&Bucket {
- name: query.name.clone(),
- timestamp: new_time,
- deleted: false,
- authorized_keys: vec![],
- })
+ .insert(&Bucket::new(query.name.clone(), new_time, false, vec![]))
.await?;
Ok(AdminRPC::Ok(format!("Bucket {} was created.", query.name)))
}
@@ -143,12 +138,12 @@ impl AdminRpcHandler {
}
self.garage
.bucket_table
- .insert(&Bucket {
- name: query.name.clone(),
- timestamp: std::cmp::max(bucket.timestamp + 1, now_msec()),
- deleted: true,
- authorized_keys: vec![],
- })
+ .insert(&Bucket::new(
+ query.name.clone(),
+ std::cmp::max(bucket.timestamp + 1, now_msec()),
+ true,
+ vec![],
+ ))
.await?;
Ok(AdminRPC::Ok(format!("Bucket {} was deleted.", query.name)))
}
@@ -292,7 +287,7 @@ impl AdminRpcHandler {
.get(&version.bucket, &version.key)
.await?;
let version_exists = match object {
- Some(o) => o.versions.iter().any(|x| x.uuid == version.uuid),
+ Some(o) => o.versions().iter().any(|x| x.uuid == version.uuid),
None => {
warn!(
"Repair versions: object for version {:?} not found",
@@ -305,13 +300,13 @@ impl AdminRpcHandler {
info!("Repair versions: marking version as deleted: {:?}", version);
self.garage
.version_table
- .insert(&Version {
- uuid: version.uuid,
- deleted: true,
- blocks: vec![],
- bucket: version.bucket,
- key: version.key,
- })
+ .insert(&Version::new(
+ version.uuid,
+ version.bucket,
+ version.key,
+ true,
+ vec![],
+ ))
.await?;
}