Custom storage example
This commit is contained in:
parent
6c3dfbc52f
commit
f2ae2f67f4
2 changed files with 30 additions and 6 deletions
|
|
@ -405,6 +405,26 @@ impl ManagedTorrent {
|
|||
})
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
pub fn wait_until_initialized(&self) -> BoxFuture<'_, anyhow::Result<()>> {
|
||||
async move {
|
||||
// TODO: rewrite, this polling is horrible
|
||||
loop {
|
||||
let done = self.with_state(|s| match s {
|
||||
ManagedTorrentState::Initializing(_) => Ok(false),
|
||||
ManagedTorrentState::Error(e) => bail!("{:?}", e),
|
||||
ManagedTorrentState::None => bail!("bug: torrent state is None"),
|
||||
_ => Ok(true),
|
||||
})?;
|
||||
if done {
|
||||
return Ok(());
|
||||
}
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
}
|
||||
}
|
||||
.boxed()
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
pub fn wait_until_completed(&self) -> BoxFuture<'_, anyhow::Result<()>> {
|
||||
async move {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue