|
|
|
@ -14,7 +14,7 @@ async fn process_next_result(mut actor: ClientActor, result: ClientTaskResult) - |
|
|
|
use ClientActorMessageHandle::{Download, GetData};
|
|
|
|
|
|
|
|
match result {
|
|
|
|
Err(e) => {
|
|
|
|
Err(mut e) => {
|
|
|
|
info!("Retry failed download: {:?}", e);
|
|
|
|
// retry ... instead of responing here we could also respond
|
|
|
|
// with something that in turn would be used to retry...
|
|
|
|
@ -22,16 +22,26 @@ async fn process_next_result(mut actor: ClientActor, result: ClientTaskResult) - |
|
|
|
actor.tasks.spawn(async move {
|
|
|
|
match e.action {
|
|
|
|
Download { .. } => {
|
|
|
|
client.download( e.action.filename()
|
|
|
|
, &e.action.uri()
|
|
|
|
, &HeaderMap::new() ).await
|
|
|
|
. map_err(|source| ClientActorError::new(&e.action, source))?;
|
|
|
|
Ok(Some(e.action))
|
|
|
|
let result = client.download( e.action.filename()
|
|
|
|
, &e.action.uri()
|
|
|
|
, &HeaderMap::new()).await;
|
|
|
|
match result {
|
|
|
|
Err(source) => Err(ClientActorError::new(&e.action, source)),
|
|
|
|
Ok(state) => {
|
|
|
|
e.action.set_state(state);
|
|
|
|
Ok(Some(e.action))
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
GetData { .. } => {
|
|
|
|
client.data(&e.action.uri(), &HeaderMap::new()).await
|
|
|
|
. map_err(|source| ClientActorError::new(&e.action, source))?;
|
|
|
|
Ok(Some(e.action))
|
|
|
|
let result = client.data(&e.action.uri(), &HeaderMap::new()).await;
|
|
|
|
match result {
|
|
|
|
Err(source) => Err(ClientActorError::new(&e.action, source)),
|
|
|
|
Ok(data) => {
|
|
|
|
*e.action.buffer_mut() = Some(data);
|
|
|
|
Ok(Some(e.action))
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|