Lock file maintenance #8
1 changed files with 83 additions and 77 deletions
|
@ -97,7 +97,12 @@ impl CaStore {
|
|||
let string_id = lexicographic_base64::encode(id.to_be_bytes());
|
||||
let source_fname = format!("temp/{string_id}");
|
||||
|
||||
/*info!("Starting multipart upload {id}");
|
||||
let mut buf = BytesMut::with_capacity(5_000_000);
|
||||
reader.read_buf(&mut buf).await?;
|
||||
let hasher = Arc::new(Mutex::new(Hasher::new()));
|
||||
|
||||
let hash = if buf.len() >= 5_000_000 {
|
||||
info!("Starting multipart upload {id}");
|
||||
let multipart_result = self
|
||||
.client
|
||||
.create_multipart_upload()
|
||||
|
@ -107,6 +112,8 @@ impl CaStore {
|
|||
.await
|
||||
.with_context(|| format!("Creating multipart request for Request ID{id}"))?;
|
||||
|
||||
let mut reader = buf.chain(reader);
|
||||
|
||||
let mut buf = BytesMut::with_capacity(16 * 1024 * 1024); // 16MiB byte buffer for the file
|
||||
let hasher = Arc::new(Mutex::new(Hasher::new()));
|
||||
|
||||
|
@ -163,11 +170,9 @@ impl CaStore {
|
|||
.set_upload_id(multipart_result.upload_id)
|
||||
.send()
|
||||
.await
|
||||
.context("Completing multipart upload")?;*/
|
||||
|
||||
let hasher = Arc::new(Mutex::new(Hasher::new()));
|
||||
let mut buf = Vec::new();
|
||||
reader.read_to_end(&mut buf).await?;
|
||||
.context("Completing multipart upload")?;
|
||||
hash
|
||||
} else {
|
||||
let buf = Bytes::from(buf);
|
||||
let buf2 = buf.clone();
|
||||
let hasher2 = Arc::clone(&hasher);
|
||||
|
@ -184,7 +189,8 @@ impl CaStore {
|
|||
.await
|
||||
.context("Uploading file")?;
|
||||
|
||||
let hash = hasher.lock().await.finalize();
|
||||
hasher.lock().await.finalize()
|
||||
};
|
||||
|
||||
let target_fname = lexicographic_base64::encode(hash.as_bytes());
|
||||
|
||||
|
|
Loading…
Reference in a new issue