Skip to content

Commit

Permalink
Add random string in path generation (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
logan-keede authored Jan 27, 2025
1 parent f0cda70 commit b80af30
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sqllogictest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ subst = "0.3"
tempfile = "3"
thiserror = "2"
tracing = "0.1"
rand = "0.8.5"

[dev-dependencies]
pretty_assertions = "1"
8 changes: 7 additions & 1 deletion sqllogictest/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use futures::{stream, Future, FutureExt, StreamExt};
use itertools::Itertools;
use md5::Digest;
use owo_colors::OwoColorize;
use rand::Rng;
use similar::{Change, ChangeTag, TextDiff};

use crate::parser::*;
Expand Down Expand Up @@ -1339,7 +1340,12 @@ impl<D: AsyncDB, M: MakeConnection<Conn = D>> Runner<D, M> {

fn create_outfile(filename: impl AsRef<Path>) -> std::io::Result<(PathBuf, File)> {
let filename = filename.as_ref();
let outfilename = filename.file_name().unwrap().to_str().unwrap().to_owned() + ".temp";
let outfilename = format!(
"{}{:010}{}",
filename.file_name().unwrap().to_str().unwrap().to_owned(),
rand::thread_rng().gen_range(0..10_000_000),
".temp"
);
let outfilename = filename.parent().unwrap().join(outfilename);
// create a temp file in read-write mode
let outfile = OpenOptions::new()
Expand Down

0 comments on commit b80af30

Please sign in to comment.