Avoid unnecessary re-downloading if |solana-install init| is invoked repeatedly (#4611)

This commit is contained in:
Michael Vines 2019-06-08 17:15:16 -07:00 committed by GitHub
parent 177c9cc026
commit a357d08524
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -283,8 +283,17 @@ pub fn init(
update_manifest_pubkey: &Pubkey, update_manifest_pubkey: &Pubkey,
no_modify_path: bool, no_modify_path: bool,
) -> Result<(), String> { ) -> Result<(), String> {
let config = {
// Write new config file only if different, so that running |solana-install init|
// repeatedly doesn't unnecessarily re-download
let mut current_config = Config::load(config_file).unwrap_or_default();
current_config.current_update_manifest = None;
let config = Config::new(data_dir, json_rpc_url, update_manifest_pubkey); let config = Config::new(data_dir, json_rpc_url, update_manifest_pubkey);
if current_config != config {
config.save(config_file)?; config.save(config_file)?;
}
config
};
update(config_file)?; update(config_file)?;
let mut modified_rcfiles = false; let mut modified_rcfiles = false;