Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Replace std::env::home_dir() with home crate impl. #9293

Merged
merged 1 commit into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions Cargo.lock

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

166 changes: 0 additions & 166 deletions README.md

This file was deleted.

5 changes: 2 additions & 3 deletions parity/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
use semver::{Version, SemVerError};
use std::collections::*;
use std::fs::{self, File, create_dir_all};
use std::env;
use std::io;
use std::io::{Read, Write};
use std::path::{PathBuf, Path};
use dir::{DatabaseDirectories, default_data_path};
use dir::{DatabaseDirectories, default_data_path, home_dir};
use dir::helpers::replace_home;
use journaldb::Algorithm;

Expand Down Expand Up @@ -201,7 +200,7 @@ fn upgrade_user_defaults(dirs: &DatabaseDirectories) {
}

pub fn upgrade_data_paths(base_path: &str, dirs: &DatabaseDirectories, pruning: Algorithm) {
if env::home_dir().is_none() {
if home_dir().is_none() {
return;
}

Expand Down
3 changes: 2 additions & 1 deletion util/dir/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[package]
name = "dir"
version = "0.1.1"
version = "0.1.2"
authors = ["Parity Technologies <admin@parity.io>"]
license = "GPL3"

[dependencies]
ethereum-types = "0.3"
journaldb = { path = "../journaldb" }
app_dirs = { git = "https://github.com/paritytech/app-dirs-rs" }
home = "0.3"
4 changes: 2 additions & 2 deletions util/dir/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

//! Directory helper functions
use std::env;
use ::home_dir;

/// Replaces `$HOME` str with home directory path.
pub fn replace_home(base: &str, arg: &str) -> String {
// the $HOME directory on mac os should be `~/Library` or `~/Library/Application Support`
// We use an `if` so that we don't need to call `home_dir()` if not necessary.
let r = if arg.contains("$HOME") {
arg.replace("$HOME", env::home_dir().expect("$HOME isn't defined").to_str().unwrap())
arg.replace("$HOME", home_dir().expect("$HOME isn't defined").to_str().unwrap())
} else {
arg.to_owned()
};
Expand Down
Loading