stop using old tempdir crate

This commit is contained in:
Scott Lamb
2021-05-17 13:08:01 -07:00
parent 13b497e243
commit 603f02b686
7 changed files with 30 additions and 61 deletions

View File

@@ -36,7 +36,7 @@ protobuf = { git = "https://github.com/stepancheg/rust-protobuf" }
ring = "0.16.2"
rusqlite = "0.25.3"
smallvec = "1.0"
tempdir = "0.3"
tempfile = "3.2.0"
time = "0.1"
uuid = { version = "0.8", features = ["std", "v4"] }
itertools = "0.10.0"

View File

@@ -2506,7 +2506,10 @@ mod tests {
testutil::init();
let conn = setup_conn();
let db = Database::new(clock::RealClocks {}, conn, true).unwrap();
let tmpdir = tempdir::TempDir::new("moonfire-nvr-test").unwrap();
let tmpdir = tempfile::Builder::new()
.prefix("moonfire-nvr-test")
.tempdir()
.unwrap();
let path = tmpdir.path().to_str().unwrap().to_owned();
let sample_file_dir_id = { db.lock() }.add_sample_file_dir(path).unwrap();
let mut c = CameraChange {

View File

@@ -15,7 +15,7 @@ use rusqlite;
use std::env;
use std::sync::Arc;
use std::thread;
use tempdir::TempDir;
use tempfile::TempDir;
use time;
use uuid::Uuid;
@@ -67,7 +67,10 @@ impl<C: Clocks + Clone> TestDb<C> {
}
pub(crate) fn new_with_flush_if_sec(clocks: C, flush_if_sec: i64) -> Self {
let tmpdir = TempDir::new("moonfire-nvr-test").unwrap();
let tmpdir = tempfile::Builder::new()
.prefix("moonfire-nvr-test")
.tempdir()
.unwrap();
let mut conn = rusqlite::Connection::open_in_memory().unwrap();
db::init(&mut conn).unwrap();

View File

@@ -199,7 +199,9 @@ mod tests {
#[test]
fn upgrade_and_compare() -> Result<(), Error> {
testutil::init();
let tmpdir = tempdir::TempDir::new("moonfire-nvr-test")?;
let tmpdir = tempfile::Builder::new()
.prefix("moonfire-nvr-test")
.tempdir()?;
//let path = tmpdir.path().to_str().ok_or_else(|| format_err!("invalid UTF-8"))?.to_owned();
let mut upgraded = new_conn()?;
upgraded.execute_batch(include_str!("v0.sql"))?;

View File

@@ -1045,7 +1045,7 @@ mod tests {
struct Harness {
db: Arc<db::Database<SimulatedClocks>>,
dir_id: i32,
_tmpdir: ::tempdir::TempDir,
_tmpdir: ::tempfile::TempDir,
dir: MockDir,
channel: super::SyncerChannel<MockFile>,
syncer: super::Syncer<SimulatedClocks, MockDir>,