From 0987022e218333c6ce9249eb273ee0d39bc374b3 Mon Sep 17 00:00:00 2001 From: Friedel Ziegelmayer Date: Wed, 8 Nov 2023 10:24:32 +0100 Subject: [PATCH] fix(iroh-bytes): ensure to flush file to disk (#1778) The content was not always on disk before emitting progress events and returning, resulting in broken progress updates and unfinished writes. --- iroh-bytes/src/store/flat.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/iroh-bytes/src/store/flat.rs b/iroh-bytes/src/store/flat.rs index 76bc058902..6a27a3a89b 100644 --- a/iroh-bytes/src/store/flat.rs +++ b/iroh-bytes/src/store/flat.rs @@ -734,6 +734,8 @@ impl super::Store for Store { offset += chunk.len() as u64; progress.try_send(ImportProgress::CopyProgress { id, offset })?; } + writer.flush().await?; + drop(writer); let file = ImportFile::TempFile(temp_data_path); rt.spawn_blocking(move || this.finalize_import_sync(file, format, id, progress)) .map(flatten_to_io)