about summary refs log tree commit diff
path: root/kittybox-rs/src
diff options
context:
space:
mode:
Diffstat (limited to 'kittybox-rs/src')
-rw-r--r--kittybox-rs/src/media/storage/file.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/kittybox-rs/src/media/storage/file.rs b/kittybox-rs/src/media/storage/file.rs
index 824f326..6d7068b 100644
--- a/kittybox-rs/src/media/storage/file.rs
+++ b/kittybox-rs/src/media/storage/file.rs
@@ -62,17 +62,21 @@ impl MediaStore for FileStore {
         let mut length: usize = 0;
 
         while let Some(chunk) = content.next().await {
-            // TODO consider getting rid of this Arc as we only need immutable references
-            // I don't think we quite need refcounting here
-            let chunk = std::sync::Arc::new(chunk.map_err(|err| MediaStoreError {
+            let chunk = chunk.map_err(|err| MediaStoreError {
                 kind: ErrorKind::Backend,
                 source: Some(Box::new(err)),
                 msg: "Failed to read a data chunk".to_owned()
-            })?);
+            })?;
             debug!("Read {} bytes from the stream", chunk.len());
             length += chunk.len();
             let (write_result, _hasher) = tokio::join!(
-                tempfile.write_all(&*chunk),
+                {
+                    let chunk = chunk.clone();
+                    let tempfile = &mut tempfile;
+                    async move {
+                        tempfile.write_all(&*chunk).await
+                    }
+                },
                 {
                     let chunk = chunk.clone();
                     tokio::task::spawn_blocking(move || {