Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
aspect committed Sep 11, 2024
1 parent eba4412 commit d8028c2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "khost"
version = "0.3.0"
version = "0.4.0"
edition = "2021"
authors = ["Kaspa developers"]
license = "MIT OR Apache-2.0"
Expand Down
27 changes: 17 additions & 10 deletions src/kaspad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,24 +524,31 @@ pub fn purge_data_folder(config: &Config) -> Result<()> {
}

pub fn check_for_updates(ctx: &Context) -> Result<bool> {
let mut verbose = true;
let mut updates = Vec::new();
for origin in unique_origins(ctx) {
let path = folder(&origin);

let latest = git::latest_commit_hash(&origin, true)?;
let current = git::hash(path, true)?;
if latest != current {
log::info(format!(
"Kaspad p2p node update available ({origin}): {current} -> {latest}"
))?;
updates.push((origin, current, latest));
if !path.exists() {
updates.push(origin);
verbose = false;
} else {
let latest = git::latest_commit_hash(&origin, true)?;
let current = git::hash(path, true)?;
if latest != current {
log::info(format!(
"Kaspad p2p node update available ({origin}): {current} -> {latest}"
))?;
updates.push(origin);
}
}
}

if !updates.is_empty()
&& confirm("Update Kaspad p2p node?")
.initial_value(true)
.interact()?
&& (!verbose
|| confirm("Update Kaspad p2p node?")
.initial_value(true)
.interact()?)
{
update(ctx)?;
Ok(true)
Expand Down

0 comments on commit d8028c2

Please sign in to comment.