aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-09-30 22:19:19 +0200
committermetamuffin <metamuffin@disroot.org>2023-09-30 22:19:19 +0200
commitd546caa3f5053ade763430490911fefd6257af9f (patch)
tree5834ea5aa352239ab9a3f57ee96dee20af51ca77 /client
parentc8fe73a7b160d4ada3136de9c87ad2eb0091ff7b (diff)
downloadjellything-d546caa3f5053ade763430490911fefd6257af9f.tar
jellything-d546caa3f5053ade763430490911fefd6257af9f.tar.bz2
jellything-d546caa3f5053ade763430490911fefd6257af9f.tar.zst
make cache async and fix parallel write bug
Diffstat (limited to 'client')
-rw-r--r--client/Cargo.toml1
-rw-r--r--client/src/lib.rs5
2 files changed, 4 insertions, 2 deletions
diff --git a/client/Cargo.toml b/client/Cargo.toml
index ea89057..05dd2d4 100644
--- a/client/Cargo.toml
+++ b/client/Cargo.toml
@@ -9,3 +9,4 @@ log = { workspace = true }
reqwest = { version = "0.11.20", features = ["json"] }
anyhow = "1.0.75"
serde_json = "1.0.107"
+tokio = { workspace = true }
diff --git a/client/src/lib.rs b/client/src/lib.rs
index 200c869..92545a9 100644
--- a/client/src/lib.rs
+++ b/client/src/lib.rs
@@ -12,6 +12,7 @@ use reqwest::{
use serde_json::json;
use std::time::Duration;
use stream::StreamSpec;
+use tokio::io::AsyncWriteExt;
pub use jellycommon::*;
@@ -93,7 +94,7 @@ impl Session {
&self,
id: &str,
role: &str,
- mut writer: impl std::io::Write,
+ mut writer: impl tokio::io::AsyncWrite + std::marker::Unpin,
) -> Result<()> {
debug!("downloading asset {role:?} for {id:?}");
let mut r = self
@@ -102,7 +103,7 @@ impl Session {
.send()
.await?;
while let Some(chunk) = r.chunk().await? {
- writer.write_all(&chunk)?;
+ writer.write_all(&chunk).await?;
}
Ok(())
}