drop states in block
This commit is contained in:
17
src/main.rs
17
src/main.rs
@@ -86,14 +86,15 @@ impl Downloader {
|
|||||||
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
|
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
|
||||||
|
|
||||||
// notify all waiters
|
// notify all waiters
|
||||||
let mut states = self.states.lock().await;
|
{
|
||||||
let state = states.remove(target_url).unwrap();
|
let mut states = self.states.lock().await;
|
||||||
state.result.lock().await.replace(Ok(DownloadData {
|
let state = states.remove(target_url).unwrap();
|
||||||
body: body.clone(),
|
state.result.lock().await.replace(Ok(DownloadData {
|
||||||
headers: headers.clone(),
|
body: body.clone(),
|
||||||
}));
|
headers: headers.clone(),
|
||||||
state.notify.notify_waiters();
|
}));
|
||||||
drop(states);
|
state.notify.notify_waiters();
|
||||||
|
}
|
||||||
|
|
||||||
Ok(DownloadData { body, headers })
|
Ok(DownloadData { body, headers })
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user