Merge pull request #10 from DenioD/master

change path for .dat and .log to .silentdragon, create .silendtdragonlite folder when missing
This commit is contained in:
Duke Leto
2019-11-01 11:37:02 -04:00
committed by GitHub
4 changed files with 14 additions and 47 deletions

View File

@@ -75,11 +75,11 @@ pub fn report_permission_error() {
eprintln!("HOME: {}", home);
eprintln!("Executable: {}", current_executable.display());
if home == "/" {
eprintln!("User {} must have permission to write to '{}silentdragonlite/' .",
eprintln!("User {} must have permission to write to '{}.silentdragonlite/' .",
user,
home);
} else {
eprintln!("User {} must have permission to write to '{}/silentdragonlite/' .",
eprintln!("User {} must have permission to write to '{}/.silentdragonlite/' .",
user,
home);
}
@@ -89,7 +89,7 @@ pub fn report_permission_error() {
pub fn get_log_config(config: &LightClientConfig) -> io::Result<Config> {
let window_size = 3; // log0, log1, log2
let fixed_window_roller =
FixedWindowRoller::builder().build("Silentdragonlite-light-wallet-log{}",window_size).unwrap();
FixedWindowRoller::builder().build("Silentdragonlite-wallet-log{}",window_size).unwrap();
let size_limit = 5 * 1024 * 1024; // 5MB as max log file size to roll
let size_trigger = SizeTrigger::new(size_limit);
let compound_policy = CompoundPolicy::new(Box::new(size_trigger),Box::new(fixed_window_roller));

View File

@@ -27,7 +27,7 @@ use crate::ANCHOR_OFFSET;
mod checkpoints;
pub const DEFAULT_SERVER: &str = "https://";
pub const DEFAULT_SERVER: &str = "https://hush-lightwallet.de:443";
pub const WALLET_NAME: &str = "silentdragonlite-wallet.dat";
pub const LOGFILE_NAME: &str = "silentdragonlite-wallet.debug.log";
@@ -110,7 +110,7 @@ impl LightClientConfig {
zcash_data_location.push("silentdragonlite");
} else {
zcash_data_location = dirs::home_dir().expect("Couldn't determine home directory!");
zcash_data_location.push("silentdragonlite/");
zcash_data_location.push(".silentdragonlite");
};
match &self.chain_name[..] {
@@ -120,8 +120,15 @@ impl LightClientConfig {
c => panic!("Unknown chain {}", c),
};
}
zcash_data_location.into_boxed_path()
// Create directory if it doesn't exist
match std::fs::create_dir_all(zcash_data_location.clone()) {
Ok(_) => zcash_data_location.into_boxed_path(),
Err(e) => {
eprintln!("Couldn't create zcash directory!\n{}", e);
panic!("Couldn't create zcash directory!");
}
}
}
pub fn get_wallet_path(&self) -> Box<Path> {

View File

@@ -1,20 +0,0 @@
pub fn report_permission_error() {
let user = std::env::var("USER").expect(
"Unexpected error reading value of $USER!");
let home = std::env::var("HOME").expect(
"Unexpected error reading value of $HOME!");
let current_executable = std::env::current_exe()
.expect("Unexpected error reporting executable path!");
eprintln!("USER: {}", user);
eprintln!("HOME: {}", home);
eprintln!("Executable: {}", current_executable.display());
if home == "/" {
eprintln!("User {} must have permission to write to '{}silentdragonlite/' .",
user,
home);
} else {
eprintln!("User {} must have permission to write to '{}/silentdragonlite/ .",
user,
home);
}
}

View File

@@ -1,20 +0,0 @@
pub fn report_permission_error() {
let user = std::env::var("USER").expect(
"Unexpected error reading value of $USER!");
let home = std::env::var("HOME").expect(
"Unexpected error reading value of $HOME!");
let current_executable = std::env::current_exe()
.expect("Unexpected error reporting executable path!");
eprintln!("USER: {}", user);
eprintln!("HOME: {}", home);
eprintln!("Executable: {}", current_executable.display());
if home == "/" {
eprintln!("User {} must have permission to write to '{}silentdragonlite/' .",
user,
home);
} else {
eprintln!("User {} must have permission to write to '{}/silentdragonlite/ .",
user,
home);
}
}