aboutsummaryrefslogtreecommitdiff
path: root/src/client.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/client.rs')
-rw-r--r--src/client.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/client.rs b/src/client.rs
index 2699c26..9281bce 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -1,3 +1,8 @@
+use crate::{
+ Flags,
+ cache::Cache,
+ proto::{BulkMetadata, NodeData, NodeMetadata, PlanetoidMetadata},
+};
use anyhow::{Result, bail};
use log::{debug, error, info};
use prost::{Message, bytes::Bytes};
@@ -8,12 +13,6 @@ use reqwest::{
use std::sync::atomic::{AtomicUsize, Ordering};
use tokio::sync::Semaphore;
-use crate::{
- Flags,
- cache::Cache,
- proto::{BulkMetadata, NodeData, NodeMetadata, PlanetoidMetadata},
-};
-
pub struct GeClient {
counter: AtomicUsize,
client: Client,
@@ -34,7 +33,7 @@ impl GeClient {
}
pub async fn download(&self, path: &str) -> Result<Bytes> {
let _permit = self.par_limit.acquire().await?;
- if let Some(d) = self.cache.get(path)? {
+ if let Some(d) = self.cache.get(path).await? {
debug!("cached {path:?}");
Ok(d.into())
} else {
@@ -50,7 +49,7 @@ impl GeClient {
bail!("error response")
}
let buf = res.bytes().await?;
- self.cache.insert(path, &buf)?;
+ self.cache.insert(path, &buf).await?;
Ok(buf)
}
}