multipart uploads: save timestamp
This commit is contained in:
parent
0a06fda0da
commit
942c1f1bfe
3 changed files with 20 additions and 5 deletions
|
@ -33,12 +33,13 @@ pub async fn handle_create_multipart_upload(
|
||||||
key: &str,
|
key: &str,
|
||||||
) -> Result<Response<Body>, Error> {
|
) -> Result<Response<Body>, Error> {
|
||||||
let upload_id = gen_uuid();
|
let upload_id = gen_uuid();
|
||||||
|
let timestamp = now_msec();
|
||||||
let headers = get_headers(req.headers())?;
|
let headers = get_headers(req.headers())?;
|
||||||
|
|
||||||
// Create object in object table
|
// Create object in object table
|
||||||
let object_version = ObjectVersion {
|
let object_version = ObjectVersion {
|
||||||
uuid: upload_id,
|
uuid: upload_id,
|
||||||
timestamp: now_msec(),
|
timestamp,
|
||||||
state: ObjectVersionState::Uploading {
|
state: ObjectVersionState::Uploading {
|
||||||
multipart: true,
|
multipart: true,
|
||||||
headers,
|
headers,
|
||||||
|
@ -50,7 +51,7 @@ pub async fn handle_create_multipart_upload(
|
||||||
// Create multipart upload in mpu table
|
// Create multipart upload in mpu table
|
||||||
// This multipart upload will hold references to uploaded parts
|
// This multipart upload will hold references to uploaded parts
|
||||||
// (which are entries in the Version table)
|
// (which are entries in the Version table)
|
||||||
let mpu = MultipartUpload::new(upload_id, bucket_id, key.into(), false);
|
let mpu = MultipartUpload::new(upload_id, timestamp, bucket_id, key.into(), false);
|
||||||
garage.mpu_table.insert(&mpu).await?;
|
garage.mpu_table.insert(&mpu).await?;
|
||||||
|
|
||||||
// Send success response
|
// Send success response
|
||||||
|
|
|
@ -27,6 +27,8 @@ mod v09 {
|
||||||
/// Partition key = Upload id = UUID of the object version
|
/// Partition key = Upload id = UUID of the object version
|
||||||
pub upload_id: Uuid,
|
pub upload_id: Uuid,
|
||||||
|
|
||||||
|
/// The timestamp at which the multipart upload was created
|
||||||
|
pub timestamp: u64,
|
||||||
/// Is this multipart upload deleted
|
/// Is this multipart upload deleted
|
||||||
/// The MultipartUpload is marked as deleted as soon as the
|
/// The MultipartUpload is marked as deleted as soon as the
|
||||||
/// multipart upload is either completed or aborted
|
/// multipart upload is either completed or aborted
|
||||||
|
@ -85,9 +87,16 @@ impl PartialOrd for MpuPartKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MultipartUpload {
|
impl MultipartUpload {
|
||||||
pub fn new(upload_id: Uuid, bucket_id: Uuid, key: String, deleted: bool) -> Self {
|
pub fn new(
|
||||||
|
upload_id: Uuid,
|
||||||
|
timestamp: u64,
|
||||||
|
bucket_id: Uuid,
|
||||||
|
key: String,
|
||||||
|
deleted: bool,
|
||||||
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
upload_id,
|
upload_id,
|
||||||
|
timestamp,
|
||||||
deleted: crdt::Bool::new(deleted),
|
deleted: crdt::Bool::new(deleted),
|
||||||
parts: crdt::Map::new(),
|
parts: crdt::Map::new(),
|
||||||
bucket_id,
|
bucket_id,
|
||||||
|
|
|
@ -444,8 +444,13 @@ impl TableSchema for ObjectTable {
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
if delete_mpu {
|
if delete_mpu {
|
||||||
let deleted_mpu =
|
let deleted_mpu = MultipartUpload::new(
|
||||||
MultipartUpload::new(v.uuid, old_v.bucket_id, old_v.key.clone(), true);
|
v.uuid,
|
||||||
|
v.timestamp,
|
||||||
|
old_v.bucket_id,
|
||||||
|
old_v.key.clone(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
let res = self.mpu_table.queue_insert(tx, &deleted_mpu);
|
let res = self.mpu_table.queue_insert(tx, &deleted_mpu);
|
||||||
if let Err(e) = db::unabort(res)? {
|
if let Err(e) = db::unabort(res)? {
|
||||||
error!(
|
error!(
|
||||||
|
|
Loading…
Reference in a new issue