Skip to content

Commit dba7d2e

Browse files
committed
fix: update button always self-updates (remove install-type guard)
1 parent 98f6000 commit dba7d2e

2 files changed

Lines changed: 3 additions & 50 deletions

File tree

src/ui/updater_tab.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,9 @@ impl SettingsApp {
124124
.is_some_and(|s| s.starts_with("Update available"));
125125

126126
if update_ready && ui.button("Download & Install Update").clicked() {
127-
if let Some(hint) = crate::updater::managed_install_hint() {
128-
// Don't self-update a Scoop/WinGet install — point the user
129-
// at their package manager instead.
130-
self.update_status = Some(hint);
131-
} else {
132-
let channel = self.config.updater.channel.clone();
133-
crate::updater::background_apply(channel);
134-
self.update_status = Some("Downloading update...".to_string());
135-
}
127+
let channel = self.config.updater.channel.clone();
128+
crate::updater::background_apply(channel);
129+
self.update_status = Some("Downloading update...".to_string());
136130
}
137131
});
138132

src/updater.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -189,49 +189,8 @@ fn resolve_expected_hash(
189189
None
190190
}
191191

192-
// Detected install method, used to decide whether self-update is safe.
193-
enum InstallKind {
194-
Portable,
195-
Scoop,
196-
Installer,
197-
}
198-
199-
fn install_kind() -> InstallKind {
200-
let exe = crate::win_ops::current_exe_path().to_lowercase();
201-
if exe.contains("\\scoop\\") {
202-
return InstallKind::Scoop;
203-
}
204-
// The Inno installer installs to %LOCALAPPDATA%\HideDesktopApps. Detect by the
205-
// running exe's location (not a global registry key) so a portable or dev copy
206-
// on a machine that merely ran the installer once still self-updates.
207-
if let Ok(local) = std::env::var("LOCALAPPDATA") {
208-
let install_dir = format!("{}\\hidedesktopapps\\", local.to_lowercase());
209-
if exe.starts_with(&install_dir) {
210-
return InstallKind::Installer;
211-
}
212-
}
213-
InstallKind::Portable
214-
}
215-
216-
// If this is a package-manager-managed install, returns a hint telling the user
217-
// how to upgrade instead of self-replacing (which would clobber the manager).
218-
pub fn managed_install_hint() -> Option<String> {
219-
let cmd = match install_kind() {
220-
InstallKind::Scoop => "scoop update HideDesktopApps",
221-
InstallKind::Installer => "winget upgrade Londopy.HideDesktopApps",
222-
InstallKind::Portable => return None,
223-
};
224-
Some(format!("Managed install \u{2014} update with: {cmd}"))
225-
}
226-
227192
// download the update zip and replace the running exe
228193
pub fn download_and_apply(channel: &str) -> Result<()> {
229-
// Never self-replace a package-manager-managed install; tell the user how
230-
// to upgrade through their manager instead.
231-
if let Some(hint) = managed_install_hint() {
232-
bail!("Self-update skipped. {hint}");
233-
}
234-
235194
let release = fetch_latest_release(channel)?;
236195
let suffix = arch_suffix();
237196
let client = build_client()?;

0 commit comments

Comments
 (0)