Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of the dirs dependency. #1577 #1584

Merged
merged 4 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 1 addition & 11 deletions Cargo.lock

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

10 changes: 8 additions & 2 deletions forest/src/cli/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// SPDX-License-Identifier: Apache-2.0, MIT

use chain_sync::SyncConfig;
use directories::ProjectDirs;
use forest_libp2p::Libp2pConfig;
use networks::ChainConfig;
use rpc_client::DEFAULT_PORT;
use serde::{Deserialize, Serialize};
use utils::get_home_dir;

#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(default)]
Expand Down Expand Up @@ -34,9 +34,15 @@ pub struct Config {

impl Default for Config {
fn default() -> Self {
let dir = ProjectDirs::from("com", "ChainSafe", "Forest").expect("project directories couldn't be found and that FOREST_CONFIG_PATH must be set manually.");
lemmih marked this conversation as resolved.
Show resolved Hide resolved
Self {
network: Libp2pConfig::default(),
data_dir: get_home_dir() + "/.forest",
data_dir: dir
lemmih marked this conversation as resolved.
Show resolved Hide resolved
.data_dir()
.to_path_buf()
.into_os_string()
.into_string()
.unwrap(),
genesis_file: None,
enable_rpc: true,
rpc_port: DEFAULT_PORT,
Expand Down
1 change: 0 additions & 1 deletion node/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ authors = ["ChainSafe Systems <[email protected]>"]
edition = "2021"

[dependencies]
dirs = "4.0"
toml = "0.5"
libc = "0.2"
serde = "1.0"
Expand Down
10 changes: 0 additions & 10 deletions node/utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use dirs::home_dir;
use std::fs::{create_dir_all, File};
use std::io::{prelude::*, Result};
use std::path::Path;
Expand Down Expand Up @@ -47,15 +46,6 @@ pub fn read_file_to_string(path: &Path) -> Result<String> {
Ok(string)
}

/// Gets the home directory of the current system.
/// Will return correct path for windows, linux, and osx.
///
/// # Panics
/// We will panic if we cannot determine a home directory.
pub fn get_home_dir() -> String {
home_dir().unwrap().to_str().unwrap().to_owned()
}

/// Converts a toml file represented as a string to `S`
///
/// # Example
Expand Down