mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
fix spawn scope
This commit is contained in:
@@ -543,18 +543,7 @@ async fn run_get_request(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let start = start.next(blob.hash);
|
let start = start.next(blob.hash);
|
||||||
|
let done = on_blob(context, &rt, &jobs, &ticket, start, &blob.name).await?;
|
||||||
// `iroh_io` io needs to be done on a local spawn
|
|
||||||
let ticket = ticket.clone();
|
|
||||||
let context = context.clone();
|
|
||||||
let name = blob.name.clone();
|
|
||||||
let jobs = jobs.clone();
|
|
||||||
let done = rt
|
|
||||||
.local_pool()
|
|
||||||
.spawn_pinned(move || {
|
|
||||||
Box::pin(async move { on_blob(context, jobs, ticket, start, &name).await })
|
|
||||||
})
|
|
||||||
.await??;
|
|
||||||
|
|
||||||
next = done.next();
|
next = done.next();
|
||||||
};
|
};
|
||||||
@@ -568,9 +557,10 @@ async fn run_get_request(
|
|||||||
/// This writes the blobs to the blobdir. If the blob is the database it will import it to
|
/// This writes the blobs to the blobdir. If the blob is the database it will import it to
|
||||||
/// the database of the current [`Context`].
|
/// the database of the current [`Context`].
|
||||||
async fn on_blob(
|
async fn on_blob(
|
||||||
context: Context,
|
context: &Context,
|
||||||
jobs: Arc<Mutex<JoinSet<()>>>,
|
rt: &runtime::Handle,
|
||||||
ticket: Ticket,
|
jobs: &Arc<Mutex<JoinSet<()>>>,
|
||||||
|
ticket: &Ticket,
|
||||||
state: fsm::AtBlobHeader,
|
state: fsm::AtBlobHeader,
|
||||||
name: &str,
|
name: &str,
|
||||||
) -> Result<fsm::AtEndBlob> {
|
) -> Result<fsm::AtEndBlob> {
|
||||||
@@ -592,12 +582,23 @@ async fn on_blob(
|
|||||||
context.get_blobdir().join(blobname)
|
context.get_blobdir().join(blobname)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// `iroh_io` io needs to be done on a local spawn
|
||||||
let file_path = path.clone();
|
let file_path = path.clone();
|
||||||
let mut file = iroh_io::File::create(move || std::fs::File::create(&file_path)).await?;
|
let done = rt
|
||||||
|
.local_pool()
|
||||||
|
.spawn_pinned(move || {
|
||||||
|
let file_path = file_path.clone();
|
||||||
|
Box::pin(async move {
|
||||||
|
let mut file =
|
||||||
|
iroh_io::File::create(move || std::fs::File::create(&file_path)).await?;
|
||||||
// TODO: ProgressEmitter doesn't support writers :(
|
// TODO: ProgressEmitter doesn't support writers :(
|
||||||
// let mut wrapped_file = progress.wrap_async_write(&mut file);
|
// let mut wrapped_file = progress.wrap_async_write(&mut file);
|
||||||
let done = state.write_all(&mut file).await?;
|
let done = state.write_all(&mut file).await?;
|
||||||
file.sync().await?;
|
file.sync().await?;
|
||||||
|
anyhow::Ok(done)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.await??;
|
||||||
|
|
||||||
if name.starts_with("db/") {
|
if name.starts_with("db/") {
|
||||||
let context = context.clone();
|
let context = context.clone();
|
||||||
|
|||||||
Reference in New Issue
Block a user