From b3c88da1815a35e8a60a39c83b4dae67926ba07d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 19 Nov 2020 12:50:25 -0400 Subject: [PATCH] fix windows assistant upgrade glitch Prevent windows assistant from trying (and failing) to upgrade itself, which has never been supported on windows. The new windows build is made with UPGRADE_LOCATION set, which enabled this code path that had never run on windows before, and doesn't work. I don't want to try to support self-upgrade on windows, or generally on other OS's than the ones where its working, so added a check for that. This way the build can keep setting UPGRADE_LOCATION and if some later git-annex does learn how to upgrade itself on some OS, it won't need changing the build setup. --- Assistant/Threads/Upgrader.hs | 2 +- Assistant/Upgrade.hs | 12 ++++++++++++ Assistant/WebApp/Configurators/Preferences.hs | 4 ++-- CHANGELOG | 2 ++ doc/bugs/Upgrader_crashed.mdwn | 3 +++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Assistant/Threads/Upgrader.hs b/Assistant/Threads/Upgrader.hs index 4fff909203..a0e39e4174 100644 --- a/Assistant/Threads/Upgrader.hs +++ b/Assistant/Threads/Upgrader.hs @@ -31,7 +31,7 @@ import qualified Data.Text as T upgraderThread :: UrlRenderer -> NamedThread upgraderThread urlrenderer = namedThread "Upgrader" $ - when (isJust BuildInfo.upgradelocation) $ do + when upgradeSupported $ do {- Check for upgrade on startup, unless it was just - upgraded. -} unlessM (liftIO checkSuccessfulUpgrade) $ diff --git a/Assistant/Upgrade.hs b/Assistant/Upgrade.hs index db6f6a26e0..b61eff54c0 100644 --- a/Assistant/Upgrade.hs +++ b/Assistant/Upgrade.hs @@ -338,6 +338,18 @@ distributionInfoUrl = fromJust BuildInfo.upgradelocation ++ ".info" distributionInfoSigUrl :: String distributionInfoSigUrl = distributionInfoUrl ++ ".sig" +{- Upgrade only supported on linux and OSX. -} +upgradeSupported :: Bool +#ifdef linux_HOST_OS +upgradeSupported = isJust BuildInfo.upgradelocation +#else +#ifdef darwin_HOST_OS +upgradeSupported = isJust BuildInfo.upgradelocation +#else +upgradeSupported = False +#endif +#endif + {- Verifies that a file from the git-annex distribution has a valid - signature. Pass the detached .sig file; the file to be verified should - be located next to it. diff --git a/Assistant/WebApp/Configurators/Preferences.hs b/Assistant/WebApp/Configurators/Preferences.hs index 59ffff71a9..d92362575e 100644 --- a/Assistant/WebApp/Configurators/Preferences.hs +++ b/Assistant/WebApp/Configurators/Preferences.hs @@ -21,7 +21,7 @@ import Annex.NumCopies import Utility.DataUnits import Git.Config import Types.Distribution -import qualified BuildInfo +import Assistant.Upgrade import qualified Data.Text as T import qualified System.FilePath.ByteString as P @@ -59,7 +59,7 @@ prefsAForm d = PrefsForm , ("disabled", NoAutoUpgrade) ] autoUpgradeLabel - | isJust BuildInfo.upgradelocation = "Auto upgrade" + | upgradeSupported = "Auto upgrade" | otherwise = "Auto restart on upgrade" positiveIntField = check isPositive intField diff --git a/CHANGELOG b/CHANGELOG index e914ee55f6..fc0db5e3d0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,8 @@ git-annex (8.20201117) UNRELEASED; urgency=medium the stderr pipe to it was left open, due to a daemon having inherited the file descriptor. * Fix build on Windows. + * Prevent windows assistant from trying (and failing) to upgrade + itself, which has never been supported on windows. -- Joey Hess Mon, 16 Nov 2020 09:38:32 -0400 diff --git a/doc/bugs/Upgrader_crashed.mdwn b/doc/bugs/Upgrader_crashed.mdwn index 89fb403b15..b9b8238f41 100644 --- a/doc/bugs/Upgrader_crashed.mdwn +++ b/doc/bugs/Upgrader_crashed.mdwn @@ -37,3 +37,6 @@ Upgrader crashed: C:\Users\alexasus\.config\git-annex\program: openFile: does no I've barely just installed. So I'm gonna get going these days. That warning doesn't seem to be an issue so far. I've looked it up but couldn't find any other reports for that warning. + +> [[fixed|done]] (by skipping checking upgrades on OS's where it's not +> supported) --[[Joey]]