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

Fix cache path when using --base-path #6212

Merged
merged 1 commit into from
Aug 2, 2017
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
18 changes: 13 additions & 5 deletions parity/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -905,13 +905,10 @@ impl Configuration {
} else {
self.args.flag_db_path.as_ref().map_or(dir::CHAINS_PATH, |s| &s)
};
let cache_path = if is_using_base_path {
"$BASE/cache".into()
} else {
replace_home_and_local(&data_path, &local_path, &dir::CACHE_PATH)
};
let cache_path = if is_using_base_path { "$BASE/cache" } else { dir::CACHE_PATH };

let db_path = replace_home_and_local(&data_path, &local_path, &base_db_path);
let cache_path = replace_home_and_local(&data_path, &local_path, cache_path);
let keys_path = replace_home(&data_path, &self.args.flag_keys_path);
let dapps_path = replace_home(&data_path, &self.args.flag_dapps_path);
let secretstore_path = replace_home(&data_path, &self.args.flag_secretstore_path);
Expand Down Expand Up @@ -1806,4 +1803,15 @@ mod tests {
custom_block: vec![IpNetwork::from_str("fc00::/7").unwrap()],
});
}

#[test]
fn should_use_correct_cache_path_if_base_is_set() {
let std = parse(&["parity"]);
let base = parse(&["parity", "--base-path", "/test"]);

let base_path = ::dir::default_data_path();
let local_path = ::dir::default_local_path();
assert_eq!(std.directories().cache, ::helpers::replace_home_and_local(&base_path, &local_path, ::dir::CACHE_PATH));
assert_eq!(base.directories().cache, "/test/cache");
}
}