replace tempdir by tempfile (#2143)

## Issue Addressed

Fixes #2141 
Remove [tempdir](https://docs.rs/tempdir/0.3.7/tempdir/) in favor of [tempfile](https://docs.rs/tempfile/3.1.0/tempfile/).

## Proposed Changes

`tempfile` has a slightly different api that makes creating temp folders with a name prefix a chore (`tempdir::TempDir::new("toto")` => `tempfile::Builder::new().prefix("toto").tempdir()`).

So I removed temp folder name prefix where I deemed it not useful.

Otherwise, the functionality is the same.
This commit is contained in:
Arthur Woimbée
2021-01-06 06:36:11 +00:00
parent 7e4b190df0
commit 851a4dca3c
21 changed files with 64 additions and 74 deletions

View File

@@ -88,12 +88,12 @@ pub mod tests_commons {
pub use crate::Storage;
use helpers::*;
use sloggers::{null::NullLoggerBuilder, Build};
use tempdir::TempDir;
use tempfile::{tempdir, TempDir};
type T = StorageRawDir;
pub fn new_storage_with_tmp_dir() -> (T, TempDir) {
let tmp_dir = TempDir::new("bls-remote-signer-test").unwrap();
let tmp_dir = tempdir().unwrap();
let storage = StorageRawDir::new(tmp_dir.path().to_str().unwrap()).unwrap();
(storage, tmp_dir)
}
@@ -104,7 +104,7 @@ pub mod tests_commons {
}
pub fn new_backend_for_get_keys() -> (Backend<T>, TempDir) {
let tmp_dir = TempDir::new("bls-remote-signer-test").unwrap();
let tmp_dir = tempdir().unwrap();
let matches = set_matches(vec![
"this_test",
@@ -145,7 +145,7 @@ pub mod backend_new {
use super::*;
use crate::tests_commons::*;
use helpers::*;
use tempdir::TempDir;
use tempfile::tempdir;
#[test]
fn no_storage_type_supplied() {
@@ -170,7 +170,7 @@ pub mod backend_new {
#[test]
fn given_inaccessible() {
let tmp_dir = TempDir::new("bls-remote-signer-test").unwrap();
let tmp_dir = tempdir().unwrap();
set_permissions(tmp_dir.path(), 0o40311);
let matches = set_matches(vec![