diff options
author | Alex Auvolat <alex@adnab.me> | 2020-07-08 17:33:24 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-07-08 17:33:24 +0200 |
commit | 64a6eda0d2bb6aae6a6eef60032ab24ae3c37a88 (patch) | |
tree | 9e3501aba850af7b2e3453e3bba4b3afce007852 /src/api/s3_copy.rs | |
parent | 84bbbfaa7b670d6dd1501aeecc6c44251819d4ae (diff) | |
download | garage-64a6eda0d2bb6aae6a6eef60032ab24ae3c37a88.tar.gz garage-64a6eda0d2bb6aae6a6eef60032ab24ae3c37a88.zip |
Migrate S3 api to use new model
Diffstat (limited to 'src/api/s3_copy.rs')
-rw-r--r-- | src/api/s3_copy.rs | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/api/s3_copy.rs b/src/api/s3_copy.rs index 0af1b13a..b54701e2 100644 --- a/src/api/s3_copy.rs +++ b/src/api/s3_copy.rs @@ -39,27 +39,23 @@ pub async fn handle_copy( Some(v) => v, None => return Err(Error::NotFound), }; + let source_last_state = match &source_last_v.state { + ObjectVersionState::Complete(x) => x, + _ => unreachable!(), + }; let new_uuid = gen_uuid(); let dest_object_version = ObjectVersion { uuid: new_uuid, timestamp: now_msec(), - mime_type: source_last_v.mime_type.clone(), - size: source_last_v.size, - state: ObjectVersionState::Complete, - data: source_last_v.data.clone(), + state: ObjectVersionState::Complete(source_last_state.clone()), }; - match &source_last_v.data { - ObjectVersionData::Uploading => { - return Err(Error::Message(format!( - "Version is_complete() but data is stil Uploading (internal error)" - ))); - } + match &source_last_state { ObjectVersionData::DeleteMarker => { return Err(Error::NotFound); } - ObjectVersionData::Inline(_bytes) => { + ObjectVersionData::Inline(_meta, _bytes) => { let dest_object = Object::new( dest_bucket.to_string(), dest_key.to_string(), @@ -67,7 +63,7 @@ pub async fn handle_copy( ); garage.object_table.insert(&dest_object).await?; } - ObjectVersionData::FirstBlock(_first_block_hash) => { + ObjectVersionData::FirstBlock(_meta, _first_block_hash) => { let source_version = garage .version_table .get(&source_last_v.uuid, &EmptyKey) |