aboutsummaryrefslogtreecommitdiff
path: root/src/api_server.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-04-09 16:16:27 +0200
committerAlex Auvolat <alex@adnab.me>2020-04-09 16:16:27 +0200
commit4c1aee42d5032066272a051687ac200e874cc13f (patch)
tree9046b13a60687fd5367dce59c246523b8585e236 /src/api_server.rs
parenta450103ed038d0838b1a1336ffd3a011abdd88a4 (diff)
downloadgarage-4c1aee42d5032066272a051687ac200e874cc13f.tar.gz
garage-4c1aee42d5032066272a051687ac200e874cc13f.zip
Reorganize table API
Diffstat (limited to 'src/api_server.rs')
-rw-r--r--src/api_server.rs22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/api_server.rs b/src/api_server.rs
index 8acd15d8..ff7c536c 100644
--- a/src/api_server.rs
+++ b/src/api_server.rs
@@ -97,11 +97,9 @@ async fn handle_put(garage: Arc<Garage>,
None => return Err(Error::BadRequest(format!("Empty body"))),
};
- let version_key = VersionMetaKey{
- bucket: bucket.to_string(),
- key: key.to_string(),
- };
- let mut version_value = VersionMetaValue {
+ let mut version = VersionMeta{
+ bucket: bucket.into(),
+ key: key.into(),
timestamp: now_msec(),
uuid: version_uuid.clone(),
mime_type: mime_type.to_string(),
@@ -111,15 +109,15 @@ async fn handle_put(garage: Arc<Garage>,
};
if first_block.len() < INLINE_THRESHOLD {
- version_value.data = VersionData::Inline(first_block);
- version_value.is_complete = true;
- garage.version_table.insert(&version_key, &version_value).await?;
+ version.data = VersionData::Inline(first_block);
+ version.is_complete = true;
+ garage.version_table.insert(&version).await?;
return Ok(version_uuid)
}
let first_block_hash = hash(&first_block[..]);
- version_value.data = VersionData::FirstBlock(first_block_hash);
- garage.version_table.insert(&version_key, &version_value).await?;
+ version.data = VersionData::FirstBlock(first_block_hash);
+ garage.version_table.insert(&version).await?;
let block_meta = BlockMeta{
version_uuid: version_uuid.clone(),
@@ -145,8 +143,8 @@ async fn handle_put(garage: Arc<Garage>,
// TODO: if at any step we have an error, we should undo everything we did
- version_value.is_complete = true;
- garage.version_table.insert(&version_key, &version_value).await?;
+ version.is_complete = true;
+ garage.version_table.insert(&version).await?;
Ok(version_uuid)
}