Skip to content

feat(update): Add update command#80

Open
pthurlow wants to merge 2 commits into
mainfrom
feat/update-cmd
Open

feat(update): Add update command#80
pthurlow wants to merge 2 commits into
mainfrom
feat/update-cmd

Conversation

@pthurlow
Copy link
Copy Markdown
Collaborator

No description provided.

@sentry
Copy link
Copy Markdown

sentry Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 12.35955% with 156 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/update.rs 10.91% 155 Missing ⚠️
src/main.rs 75.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Comment thread src/update.rs Outdated
return;
};
let how = match detect_install_method() {
InstallMethod::Homebrew => "Run: brew upgrade hotdata",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Homebrew formula is named cli in the hotdata-dev/tap tap (see dist-workspace.toml line 15: formula = "cli", and the README install command brew install hotdata-dev/tap/cli). brew upgrade hotdata will fail with Error: No formula or cask found for hotdata, sending the user down a confusing path.

Suggest brew upgrade hotdata-dev/tap/cli (matches the README install command and works whether or not the tap is currently pinned to that formula name locally).

Suggested change
InstallMethod::Homebrew => "Run: brew upgrade hotdata",
InstallMethod::Homebrew => "Run: brew upgrade hotdata-dev/tap/cli",

Comment thread src/update.rs Outdated

if detect_install_method() == InstallMethod::Homebrew {
println!("hotdata was installed via Homebrew. Update with:");
println!(" {}", "brew upgrade hotdata".cyan());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as the notice text above — brew upgrade hotdata is not a valid formula name. Suggest matching the README install command (brew install hotdata-dev/tap/cli):

Suggested change
println!(" {}", "brew upgrade hotdata".cyan());
println!(" {}", "brew upgrade hotdata-dev/tap/cli".cyan());

Comment thread src/update.rs Outdated
if tmp_dir.exists() {
let _ = fs::remove_dir_all(&tmp_dir);
}
fs::create_dir_all(&tmp_dir).map_err(|e| format!("creating temp dir: {e}"))?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: (not blocking) Using temp_dir().join(format!("hotdata-update-{}", std::process::id())) makes the path predictable (PID is easy to observe or guess on shared/multi-user systems and on CI runners). The if exists { remove_dir_all } + create_dir_all sequence ignores errors with let _ = ..., so a pre-planted symlink survives the cleanup step (remove_dir_all on a symlink errors out and is dropped; create_dir_all succeeds on a symlink-to-existing-dir). An attacker who wins the race could redirect the tar extraction into a directory they control and have the subsequent Move::to_dest install their binary as hotdata.

tempfile is already in the transitive dep tree via self_update. Suggest tempfile::TempDir::new() (random suffix, mode 0o700) instead — it also handles cleanup on drop, which lets you drop the manual remove_dir_all calls below.

Comment thread src/update.rs
}
let xz_bytes = resp
.bytes()
.map_err(|e| format!("reading download: {e}"))?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: (not blocking) The downloaded binary isn't verified against a checksum or signature. cargo-dist publishes *.tar.xz.sha256 alongside each asset — fetching and comparing that would catch a corrupted/tampered asset before it lands as hotdata on disk. Most self-updaters skip this and TLS gives transport integrity, so this is a defense-in-depth nit rather than a real concern today.

Copy link
Copy Markdown
Contributor

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Blocking Issues

  • src/update.rs:137 and src/update.rs:154 — the Homebrew formula is named cli in the hotdata-dev/tap tap (per dist-workspace.toml formula = "cli" and the README install command). brew upgrade hotdata will fail with Error: No formula or cask found for hotdata, so the user-facing guidance directs Homebrew users to a broken command.

Action Required

Replace brew upgrade hotdata with brew upgrade hotdata-dev/tap/cli in both the update-available notice (line 137) and the hotdata update Homebrew message (line 154) so the suggestion matches the install command in the README.

Two non-blocking items left inline (temp dir predictability, optional checksum verification).

Copy link
Copy Markdown
Contributor

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All prior blocking issues resolved. The Homebrew formula is now sourced from [package.metadata.hotdata] via build.rs so the README, dist config, and binary all agree. Temp-dir extraction now uses tempfile::TempDir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant