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

Commit

Permalink
Revert "Replace std::env::home_dir with dirs::home_dir (#9077)" (#…
Browse files Browse the repository at this point in the history
…9097)

* Revert "Replace `std::env::home_dir` with `dirs::home_dir` (#9077)"

This reverts commit 7e77932.

* Restore some of the changes

* Update parity-common
  • Loading branch information
tomaka authored and 5chdn committed Jul 13, 2018
1 parent 3f53e0e commit f2ea66f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 46 deletions.
46 changes: 16 additions & 30 deletions Cargo.lock

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

7 changes: 4 additions & 3 deletions parity/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
//! Parity upgrade logic

use semver::{Version, SemVerError};
use std::collections::HashMap;
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, home_dir};
use dir::{DatabaseDirectories, default_data_path};
use dir::helpers::replace_home;
use journaldb::Algorithm;

Expand Down Expand Up @@ -105,7 +106,7 @@ fn with_locked_version<F>(db_path: Option<&str>, script: F) -> Result<usize, Err
where F: Fn(&Version) -> Result<usize, Error>
{
let mut path = db_path.map_or({
let mut path = home_dir().expect("Applications should have a home dir");
let mut path = env::home_dir().expect("Applications should have a home dir");
path.push(".parity");
path
}, PathBuf::from);
Expand Down
1 change: 0 additions & 1 deletion util/dir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ license = "GPL3"
ethereum-types = "0.3"
journaldb = { path = "../journaldb" }
app_dirs = { git = "https://github.com/paritytech/app-dirs-rs" }
dirs = "1.0.2"
3 changes: 2 additions & 1 deletion util/dir/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

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

/// 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`
let r = arg.replace("$HOME", ::dirs::home_dir().unwrap().to_str().unwrap());
let r = arg.replace("$HOME", env::home_dir().unwrap().to_str().unwrap());
let r = r.replace("$BASE", base);
r.replace("/", &::std::path::MAIN_SEPARATOR.to_string())
}
Expand Down
19 changes: 8 additions & 11 deletions util/dir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@

//! Dir utilities for platform-specific operations
extern crate app_dirs;
extern crate dirs;
extern crate ethereum_types;
extern crate journaldb;

pub mod helpers;
use std::fs;
use std::{env, fs};
use std::path::{PathBuf, Path};
use ethereum_types::{H64, H256};
use journaldb::Algorithm;
Expand All @@ -32,8 +31,6 @@ use app_dirs::{AppInfo, get_app_root, AppDataType};
// re-export platform-specific functions
use platform::*;

pub use dirs::home_dir;

/// Platform-specific chains path for standard client - Windows only
#[cfg(target_os = "windows")] pub const CHAINS_PATH: &str = "$LOCAL/chains";
/// Platform-specific chains path for light client - Windows only
Expand Down Expand Up @@ -240,7 +237,7 @@ pub fn default_hypervisor_path() -> PathBuf {

/// Get home directory.
fn home() -> PathBuf {
dirs::home_dir().expect("Failed to get home dir")
env::home_dir().expect("Failed to get home dir")
}

/// Geth path
Expand All @@ -263,9 +260,9 @@ pub fn parity(chain: &str) -> PathBuf {
#[cfg(target_os = "macos")]
mod platform {
use std::path::PathBuf;
pub const AUTHOR: &'static str = "Parity";
pub const PRODUCT: &'static str = "io.parity.ethereum";
pub const PRODUCT_HYPERVISOR: &'static str = "io.parity.ethereum-updates";
pub const AUTHOR: &str = "Parity";
pub const PRODUCT: &str = "io.parity.ethereum";
pub const PRODUCT_HYPERVISOR: &str = "io.parity.ethereum-updates";

pub fn parity_base() -> PathBuf {
let mut home = super::home();
Expand All @@ -287,9 +284,9 @@ mod platform {
#[cfg(windows)]
mod platform {
use std::path::PathBuf;
pub const AUTHOR: &'static str = "Parity";
pub const PRODUCT: &'static str = "Ethereum";
pub const PRODUCT_HYPERVISOR: &'static str = "EthereumUpdates";
pub const AUTHOR: &str = "Parity";
pub const PRODUCT: &str = "Ethereum";
pub const PRODUCT_HYPERVISOR: &str = "EthereumUpdates";

pub fn parity_base() -> PathBuf {
let mut home = super::home();
Expand Down

0 comments on commit f2ea66f

Please sign in to comment.