[offline] Use buffering for JSON file reading / writing

This commit is contained in:
Jonas Platte
2020-12-29 19:48:42 +01:00
committed by Ryan Leckey
parent ce56f191ec
commit 52a7c35439
2 changed files with 11 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ use remove_dir_all::remove_dir_all;
use sqlx::any::{AnyConnectOptions, AnyKind};
use std::collections::BTreeMap;
use std::fs::File;
use std::io::BufWriter;
use std::process::Command;
use std::str::FromStr;
use std::time::SystemTime;
@@ -32,7 +33,9 @@ pub fn run(url: &str, merge: bool, cargo_args: Vec<String>) -> anyhow::Result<()
}
serde_json::to_writer_pretty(
File::create("sqlx-data.json").context("failed to create/open `sqlx-data.json`")?,
BufWriter::new(
File::create("sqlx-data.json").context("failed to create/open `sqlx-data.json`")?,
),
&DataFile { db: db_kind, data },
)
.context("failed to write to `sqlx-data.json`")?;