@@ -34,7 +34,7 @@ pub struct Downloader {
34
34
#[ rpc_requests( message = SwarmMsg , alias = "Msg" ) ]
35
35
#[ derive( Debug , Serialize , Deserialize ) ]
36
36
enum SwarmProtocol {
37
- #[ rpc( tx = mpsc:: Sender <DownloadProgessItem >) ]
37
+ #[ rpc( tx = mpsc:: Sender <DownloadProgressItem >) ]
38
38
Download ( DownloadRequest ) ,
39
39
}
40
40
@@ -46,7 +46,7 @@ struct DownloaderActor {
46
46
}
47
47
48
48
#[ derive( Debug , Serialize , Deserialize ) ]
49
- pub enum DownloadProgessItem {
49
+ pub enum DownloadProgressItem {
50
50
#[ serde( skip) ]
51
51
Error ( anyhow:: Error ) ,
52
52
TryProvider {
@@ -98,15 +98,15 @@ impl DownloaderActor {
98
98
async fn handle_download ( store : Store , pool : ConnectionPool , msg : DownloadMsg ) {
99
99
let DownloadMsg { inner, mut tx, .. } = msg;
100
100
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 ( ) ;
102
102
}
103
103
}
104
104
105
105
async fn handle_download_impl (
106
106
store : Store ,
107
107
pool : ConnectionPool ,
108
108
request : DownloadRequest ,
109
- tx : & mut mpsc:: Sender < DownloadProgessItem > ,
109
+ tx : & mut mpsc:: Sender < DownloadProgressItem > ,
110
110
) -> anyhow:: Result < ( ) > {
111
111
match request. strategy {
112
112
SplitStrategy :: Split => handle_download_split_impl ( store, pool, request, tx) . await ?,
@@ -127,7 +127,7 @@ async fn handle_download_split_impl(
127
127
store : Store ,
128
128
pool : ConnectionPool ,
129
129
request : DownloadRequest ,
130
- tx : & mut mpsc:: Sender < DownloadProgessItem > ,
130
+ tx : & mut mpsc:: Sender < DownloadProgressItem > ,
131
131
) -> anyhow:: Result < ( ) > {
132
132
let providers = request. providers ;
133
133
let requests = split_request ( & request. request , & providers, & pool, & store, Drain ) . await ?;
@@ -140,7 +140,7 @@ async fn handle_download_split_impl(
140
140
let progress_tx = progress_tx. clone ( ) ;
141
141
async move {
142
142
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 ) ;
144
144
progress_tx. send ( rx) . await . ok ( ) ;
145
145
let sink = TokioMpscSenderSink ( tx) . with_map ( move |x| ( id, x) ) ;
146
146
let res = execute_get ( & pool, Arc :: new ( request) , & providers, & store, sink) . await ;
@@ -154,12 +154,12 @@ async fn handle_download_split_impl(
154
154
into_stream ( progress_rx)
155
155
. flat_map ( into_stream)
156
156
. map ( move |( id, item) | match item {
157
- DownloadProgessItem :: Progress ( offset) => {
157
+ DownloadProgressItem :: Progress ( offset) => {
158
158
total += offset;
159
159
if let Some ( prev) = offsets. insert ( id, offset) {
160
160
total -= prev;
161
161
}
162
- DownloadProgessItem :: Progress ( total)
162
+ DownloadProgressItem :: Progress ( total)
163
163
}
164
164
x => x,
165
165
} )
@@ -174,7 +174,7 @@ async fn handle_download_split_impl(
174
174
Some ( ( _hash, Ok ( ( ) ) ) ) => {
175
175
}
176
176
Some ( ( _hash, Err ( _e) ) ) => {
177
- tx. send( DownloadProgessItem :: DownloadError ) . await ?;
177
+ tx. send( DownloadProgressItem :: DownloadError ) . await ?;
178
178
}
179
179
None => break ,
180
180
}
@@ -298,19 +298,19 @@ impl<'de> Deserialize<'de> for DownloadRequest {
298
298
pub type DownloadOptions = DownloadRequest ;
299
299
300
300
pub struct DownloadProgress {
301
- fut : future:: Boxed < irpc:: Result < mpsc:: Receiver < DownloadProgessItem > > > ,
301
+ fut : future:: Boxed < irpc:: Result < mpsc:: Receiver < DownloadProgressItem > > > ,
302
302
}
303
303
304
304
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 {
306
306
Self { fut }
307
307
}
308
308
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 > {
310
310
let rx = self . fut . await ?;
311
311
Ok ( Box :: pin ( rx. into_stream ( ) . map ( |item| match item {
312
312
Ok ( item) => item,
313
- Err ( e) => DownloadProgessItem :: Error ( e. into ( ) ) ,
313
+ Err ( e) => DownloadProgressItem :: Error ( e. into ( ) ) ,
314
314
} ) ) )
315
315
}
316
316
@@ -320,8 +320,8 @@ impl DownloadProgress {
320
320
tokio:: pin!( stream) ;
321
321
while let Some ( item) = stream. next ( ) . await {
322
322
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" ) ,
325
325
_ => { }
326
326
}
327
327
}
@@ -372,7 +372,7 @@ async fn split_request<'a>(
372
372
providers : & Arc < dyn ContentDiscovery > ,
373
373
pool : & ConnectionPool ,
374
374
store : & Store ,
375
- progress : impl Sink < DownloadProgessItem , Error = irpc:: channel:: SendError > ,
375
+ progress : impl Sink < DownloadProgressItem , Error = irpc:: channel:: SendError > ,
376
376
) -> anyhow:: Result < Box < dyn Iterator < Item = GetRequest > + Send + ' a > > {
377
377
Ok ( match request {
378
378
FiniteRequest :: Get ( req) => {
@@ -428,13 +428,13 @@ async fn execute_get(
428
428
request : Arc < GetRequest > ,
429
429
providers : & Arc < dyn ContentDiscovery > ,
430
430
store : & Store ,
431
- mut progress : impl Sink < DownloadProgessItem , Error = irpc:: channel:: SendError > ,
431
+ mut progress : impl Sink < DownloadProgressItem , Error = irpc:: channel:: SendError > ,
432
432
) -> anyhow:: Result < ( ) > {
433
433
let remote = store. remote ( ) ;
434
434
let mut providers = providers. find_providers ( request. content ( ) ) ;
435
435
while let Some ( provider) = providers. next ( ) . await {
436
436
progress
437
- . send ( DownloadProgessItem :: TryProvider {
437
+ . send ( DownloadProgressItem :: TryProvider {
438
438
id : provider,
439
439
request : request. clone ( ) ,
440
440
} )
@@ -447,7 +447,7 @@ async fn execute_get(
447
447
let local_bytes = local. local_bytes ( ) ;
448
448
let Ok ( conn) = conn. await else {
449
449
progress
450
- . send ( DownloadProgessItem :: ProviderFailed {
450
+ . send ( DownloadProgressItem :: ProviderFailed {
451
451
id : provider,
452
452
request : request. clone ( ) ,
453
453
} )
@@ -458,21 +458,21 @@ async fn execute_get(
458
458
. execute_get_sink (
459
459
& conn,
460
460
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) ) ,
462
462
)
463
463
. await
464
464
{
465
465
Ok ( _stats) => {
466
466
progress
467
- . send ( DownloadProgessItem :: PartComplete {
467
+ . send ( DownloadProgressItem :: PartComplete {
468
468
request : request. clone ( ) ,
469
469
} )
470
470
. await ?;
471
471
return Ok ( ( ) ) ;
472
472
}
473
473
Err ( _cause) => {
474
474
progress
475
- . send ( DownloadProgessItem :: ProviderFailed {
475
+ . send ( DownloadProgressItem :: ProviderFailed {
476
476
id : provider,
477
477
request : request. clone ( ) ,
478
478
} )
0 commit comments