Skip to content

Commit c8c24d1

Browse files
IAvecillarklaehn
andauthored
chore: Fix typo in downloader code (#146)
## Description Fixed a typo in the downloader, changing `DownloaderProgessItem` to `DownloaderProgressItem` ## Breaking Changes - `DownloaderProgessItem` -> `DownloaderProgressItem` ## Change checklist - [x] Self-review. - [x] All breaking changes documented. Co-authored-by: Rüdiger Klaehn <rklaehn@protonmail.com>
1 parent a3e5ef3 commit c8c24d1

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/api/downloader.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct Downloader {
3434
#[rpc_requests(message = SwarmMsg, alias = "Msg")]
3535
#[derive(Debug, Serialize, Deserialize)]
3636
enum SwarmProtocol {
37-
#[rpc(tx = mpsc::Sender<DownloadProgessItem>)]
37+
#[rpc(tx = mpsc::Sender<DownloadProgressItem>)]
3838
Download(DownloadRequest),
3939
}
4040

@@ -46,7 +46,7 @@ struct DownloaderActor {
4646
}
4747

4848
#[derive(Debug, Serialize, Deserialize)]
49-
pub enum DownloadProgessItem {
49+
pub enum DownloadProgressItem {
5050
#[serde(skip)]
5151
Error(anyhow::Error),
5252
TryProvider {
@@ -98,15 +98,15 @@ impl DownloaderActor {
9898
async fn handle_download(store: Store, pool: ConnectionPool, msg: DownloadMsg) {
9999
let DownloadMsg { inner, mut tx, .. } = msg;
100100
if let Err(cause) = handle_download_impl(store, pool, inner, &mut tx).await {
101-
tx.send(DownloadProgessItem::Error(cause)).await.ok();
101+
tx.send(DownloadProgressItem::Error(cause)).await.ok();
102102
}
103103
}
104104

105105
async fn handle_download_impl(
106106
store: Store,
107107
pool: ConnectionPool,
108108
request: DownloadRequest,
109-
tx: &mut mpsc::Sender<DownloadProgessItem>,
109+
tx: &mut mpsc::Sender<DownloadProgressItem>,
110110
) -> anyhow::Result<()> {
111111
match request.strategy {
112112
SplitStrategy::Split => handle_download_split_impl(store, pool, request, tx).await?,
@@ -127,7 +127,7 @@ async fn handle_download_split_impl(
127127
store: Store,
128128
pool: ConnectionPool,
129129
request: DownloadRequest,
130-
tx: &mut mpsc::Sender<DownloadProgessItem>,
130+
tx: &mut mpsc::Sender<DownloadProgressItem>,
131131
) -> anyhow::Result<()> {
132132
let providers = request.providers;
133133
let requests = split_request(&request.request, &providers, &pool, &store, Drain).await?;
@@ -140,7 +140,7 @@ async fn handle_download_split_impl(
140140
let progress_tx = progress_tx.clone();
141141
async move {
142142
let hash = request.hash;
143-
let (tx, rx) = tokio::sync::mpsc::channel::<(usize, DownloadProgessItem)>(16);
143+
let (tx, rx) = tokio::sync::mpsc::channel::<(usize, DownloadProgressItem)>(16);
144144
progress_tx.send(rx).await.ok();
145145
let sink = TokioMpscSenderSink(tx).with_map(move |x| (id, x));
146146
let res = execute_get(&pool, Arc::new(request), &providers, &store, sink).await;
@@ -154,12 +154,12 @@ async fn handle_download_split_impl(
154154
into_stream(progress_rx)
155155
.flat_map(into_stream)
156156
.map(move |(id, item)| match item {
157-
DownloadProgessItem::Progress(offset) => {
157+
DownloadProgressItem::Progress(offset) => {
158158
total += offset;
159159
if let Some(prev) = offsets.insert(id, offset) {
160160
total -= prev;
161161
}
162-
DownloadProgessItem::Progress(total)
162+
DownloadProgressItem::Progress(total)
163163
}
164164
x => x,
165165
})
@@ -174,7 +174,7 @@ async fn handle_download_split_impl(
174174
Some((_hash, Ok(()))) => {
175175
}
176176
Some((_hash, Err(_e))) => {
177-
tx.send(DownloadProgessItem::DownloadError).await?;
177+
tx.send(DownloadProgressItem::DownloadError).await?;
178178
}
179179
None => break,
180180
}
@@ -298,19 +298,19 @@ impl<'de> Deserialize<'de> for DownloadRequest {
298298
pub type DownloadOptions = DownloadRequest;
299299

300300
pub struct DownloadProgress {
301-
fut: future::Boxed<irpc::Result<mpsc::Receiver<DownloadProgessItem>>>,
301+
fut: future::Boxed<irpc::Result<mpsc::Receiver<DownloadProgressItem>>>,
302302
}
303303

304304
impl DownloadProgress {
305-
fn new(fut: future::Boxed<irpc::Result<mpsc::Receiver<DownloadProgessItem>>>) -> Self {
305+
fn new(fut: future::Boxed<irpc::Result<mpsc::Receiver<DownloadProgressItem>>>) -> Self {
306306
Self { fut }
307307
}
308308

309-
pub async fn stream(self) -> irpc::Result<impl Stream<Item = DownloadProgessItem> + Unpin> {
309+
pub async fn stream(self) -> irpc::Result<impl Stream<Item = DownloadProgressItem> + Unpin> {
310310
let rx = self.fut.await?;
311311
Ok(Box::pin(rx.into_stream().map(|item| match item {
312312
Ok(item) => item,
313-
Err(e) => DownloadProgessItem::Error(e.into()),
313+
Err(e) => DownloadProgressItem::Error(e.into()),
314314
})))
315315
}
316316

@@ -320,8 +320,8 @@ impl DownloadProgress {
320320
tokio::pin!(stream);
321321
while let Some(item) = stream.next().await {
322322
match item? {
323-
DownloadProgessItem::Error(e) => Err(e)?,
324-
DownloadProgessItem::DownloadError => anyhow::bail!("Download error"),
323+
DownloadProgressItem::Error(e) => Err(e)?,
324+
DownloadProgressItem::DownloadError => anyhow::bail!("Download error"),
325325
_ => {}
326326
}
327327
}
@@ -372,7 +372,7 @@ async fn split_request<'a>(
372372
providers: &Arc<dyn ContentDiscovery>,
373373
pool: &ConnectionPool,
374374
store: &Store,
375-
progress: impl Sink<DownloadProgessItem, Error = irpc::channel::SendError>,
375+
progress: impl Sink<DownloadProgressItem, Error = irpc::channel::SendError>,
376376
) -> anyhow::Result<Box<dyn Iterator<Item = GetRequest> + Send + 'a>> {
377377
Ok(match request {
378378
FiniteRequest::Get(req) => {
@@ -428,13 +428,13 @@ async fn execute_get(
428428
request: Arc<GetRequest>,
429429
providers: &Arc<dyn ContentDiscovery>,
430430
store: &Store,
431-
mut progress: impl Sink<DownloadProgessItem, Error = irpc::channel::SendError>,
431+
mut progress: impl Sink<DownloadProgressItem, Error = irpc::channel::SendError>,
432432
) -> anyhow::Result<()> {
433433
let remote = store.remote();
434434
let mut providers = providers.find_providers(request.content());
435435
while let Some(provider) = providers.next().await {
436436
progress
437-
.send(DownloadProgessItem::TryProvider {
437+
.send(DownloadProgressItem::TryProvider {
438438
id: provider,
439439
request: request.clone(),
440440
})
@@ -447,7 +447,7 @@ async fn execute_get(
447447
let local_bytes = local.local_bytes();
448448
let Ok(conn) = conn.await else {
449449
progress
450-
.send(DownloadProgessItem::ProviderFailed {
450+
.send(DownloadProgressItem::ProviderFailed {
451451
id: provider,
452452
request: request.clone(),
453453
})
@@ -458,21 +458,21 @@ async fn execute_get(
458458
.execute_get_sink(
459459
&conn,
460460
local.missing(),
461-
(&mut progress).with_map(move |x| DownloadProgessItem::Progress(x + local_bytes)),
461+
(&mut progress).with_map(move |x| DownloadProgressItem::Progress(x + local_bytes)),
462462
)
463463
.await
464464
{
465465
Ok(_stats) => {
466466
progress
467-
.send(DownloadProgessItem::PartComplete {
467+
.send(DownloadProgressItem::PartComplete {
468468
request: request.clone(),
469469
})
470470
.await?;
471471
return Ok(());
472472
}
473473
Err(_cause) => {
474474
progress
475-
.send(DownloadProgessItem::ProviderFailed {
475+
.send(DownloadProgressItem::ProviderFailed {
476476
id: provider,
477477
request: request.clone(),
478478
})

0 commit comments

Comments
 (0)