git-annex/Command/Upgrade.hs
Joey Hess f845195354
Added annex.autoupgraderepository configuration
Can be set to false to prevent any automatic repository upgrades.

Also, removed direct mode specific upgrade code in Annex.Init, and made
needsUpgrade always include the name/path of the repo, so if
there's a problem it's clear what repo has the problem.

And, made needsUpgrade catch any exceptions that might occur during the
upgrade, so it can display a more useful error message than just the
exception.
2019-09-01 13:42:26 -04:00

33 lines
848 B
Haskell

{- git-annex command
-
- Copyright 2011 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
module Command.Upgrade where
import Command
import Upgrade
import Annex.Version
import Annex.Init
cmd :: Command
cmd = dontCheck repoExists $
-- ^ because an old version may not seem to exist
-- and also, this avoids automatic silent upgrades before
-- this command can start up.
noDaemonRunning $
-- ^ avoid upgrading repo out from under daemon
command "upgrade" SectionMaintenance "upgrade repository"
paramNothing (withParams seek)
seek :: CmdParams -> CommandSeek
seek = withNothing (commandAction start)
start :: CommandStart
start = starting "upgrade" (ActionItemOther Nothing) $ do
whenM (isNothing <$> getVersion) $ do
initialize Nothing Nothing
r <- upgrade False latestVersion
next $ return r