Replace OpenOptions::new with File::options to be readable (#3059)

## Issue Addressed

Closes #3049 

This PR updates widely but this replace is safe as `File::options()` is equivelent to `OpenOptions::new()`.
ref: https://doc.rust-lang.org/stable/src/std/fs.rs.html#378-380
This commit is contained in:
Akihito Nakano
2022-03-07 06:30:18 +00:00
parent cbda0a2f0a
commit 4186d117af
16 changed files with 40 additions and 41 deletions

View File

@@ -2,7 +2,7 @@
use eth2_wallet::Error as WalletError;
use eth2_wallet::{Uuid, Wallet};
use std::fs::{copy as copy_file, remove_file, OpenOptions};
use std::fs::{copy as copy_file, remove_file, File};
use std::io;
use std::path::{Path, PathBuf};
@@ -27,7 +27,7 @@ pub fn read<P: AsRef<Path>>(wallet_dir: P, uuid: &Uuid) -> Result<Wallet, Error>
if !json_path.exists() {
Err(Error::WalletDoesNotExist(json_path))
} else {
OpenOptions::new()
File::options()
.read(true)
.create(false)
.open(json_path)
@@ -79,7 +79,7 @@ pub fn create<P: AsRef<Path>>(wallet_dir: P, wallet: &Wallet) -> Result<(), Erro
if json_path.exists() {
Err(Error::WalletAlreadyExists(json_path))
} else {
OpenOptions::new()
File::options()
.write(true)
.create_new(true)
.open(json_path)

View File

@@ -6,7 +6,7 @@ use eth2_wallet::{bip39::Mnemonic, Error as WalletError, Uuid, Wallet, WalletBui
use lockfile::LockfileError;
use std::collections::HashMap;
use std::ffi::OsString;
use std::fs::{create_dir_all, read_dir, OpenOptions};
use std::fs::{create_dir_all, read_dir, File};
use std::io;
use std::path::{Path, PathBuf};
@@ -172,7 +172,7 @@ impl WalletManager {
// Ignore any paths that don't parse as a UUID.
if let Ok(uuid) = Uuid::parse_str(&file_name) {
let wallet_path = f.path().join(format!("{}", uuid));
let wallet = OpenOptions::new()
let wallet = File::options()
.read(true)
.create(false)
.open(wallet_path)