@@ -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
228193pub 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