use buffer when writing ipdb

This commit is contained in:
monosans
2025-12-25 10:08:32 +03:00
parent a4a7221beb
commit 0dfa840e3d
+11 -2
View File
@@ -59,15 +59,16 @@ impl DbType {
))));
let db_path = self.db_path().await?;
let mut file =
let file =
tokio::fs::File::create(&db_path).await.wrap_err_with(|| {
compact_str::format_compact!(
"failed to create file: {}",
db_path.display()
)
})?;
let mut writer = tokio::io::BufWriter::new(file);
while let Some(chunk) = response.chunk().await? {
file.write_all(&chunk).await.wrap_err_with(|| {
writer.write_all(&chunk).await.wrap_err_with(|| {
compact_str::format_compact!(
"failed to write to file: {}",
db_path.display()
@@ -81,6 +82,14 @@ impl DbType {
))),
);
}
writer.flush().await.wrap_err_with(move || {
compact_str::format_compact!(
"failed to write to file: {}",
db_path.display()
)
})?;
Ok(())
}