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
Rate limit · GitHub

Access has been restricted

You have triggered a rate limit.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.

Merged
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
Replace std::env::home_dir() with home crate impl.
* Import the `home` crate in `util/dir`.

* Replace uses of `env::home_dir()` with `home::home_dir()`.
  * `home` uses a 'correct' impl. on windows and the stdlib impl.
    of `::home_dir` otherwise.

* Reexport `home::home_dir` from `util/dir`.

* Bump `util/dir` to 0.1.2.
Rate limit · GitHub

Access has been restricted

You have triggered a rate limit.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.

c0gent committed Aug 20, 2018
commit ff0ad952b04aedb96ff836b73ca4f2b6ba074491
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
@@ -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;

@@ -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;
}

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
@@ -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()
};
Rate limit · GitHub

Access has been restricted

You have triggered a rate limit.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.