annex.autoupgrade setting
This commit is contained in:
parent
be069bd962
commit
31d43c63a4
4 changed files with 47 additions and 7 deletions
|
@ -17,6 +17,7 @@ import Assistant.DaemonStatus
|
||||||
import Assistant.Alert
|
import Assistant.Alert
|
||||||
import Utility.NotificationBroadcaster
|
import Utility.NotificationBroadcaster
|
||||||
import Utility.Tmp
|
import Utility.Tmp
|
||||||
|
import qualified Annex
|
||||||
import qualified Build.SysConfig
|
import qualified Build.SysConfig
|
||||||
import qualified Utility.Url as Url
|
import qualified Utility.Url as Url
|
||||||
import qualified Annex.Url as Url
|
import qualified Annex.Url as Url
|
||||||
|
@ -31,6 +32,7 @@ import qualified Data.Text as T
|
||||||
|
|
||||||
upgraderThread :: UrlRenderer -> NamedThread
|
upgraderThread :: UrlRenderer -> NamedThread
|
||||||
upgraderThread urlrenderer = namedThread "Upgrader" $ do
|
upgraderThread urlrenderer = namedThread "Upgrader" $ do
|
||||||
|
checkUpgrade urlrenderer
|
||||||
when (isJust Build.SysConfig.upgradelocation) $ do
|
when (isJust Build.SysConfig.upgradelocation) $ do
|
||||||
h <- liftIO . newNotificationHandle False . networkConnectedNotifier =<< getDaemonStatus
|
h <- liftIO . newNotificationHandle False . networkConnectedNotifier =<< getDaemonStatus
|
||||||
go h Nothing
|
go h Nothing
|
||||||
|
@ -40,12 +42,16 @@ upgraderThread urlrenderer = namedThread "Upgrader" $ do
|
||||||
- check. -}
|
- check. -}
|
||||||
go h lastchecked = do
|
go h lastchecked = do
|
||||||
liftIO $ waitNotification h
|
liftIO $ waitNotification h
|
||||||
now <- liftIO getCurrentTime
|
autoupgrade <- liftAnnex $ annexAutoUpgrade <$> Annex.getGitConfig
|
||||||
if maybe True (\t -> diffUTCTime now t > halfday) lastchecked
|
if autoupgrade == NoAutoUpgrade
|
||||||
then do
|
then go h lastchecked
|
||||||
checkUpgrade urlrenderer
|
else do
|
||||||
go h =<< Just <$> liftIO getCurrentTime
|
now <- liftIO getCurrentTime
|
||||||
else go h lastchecked
|
if maybe True (\t -> diffUTCTime now t > halfday) lastchecked
|
||||||
|
then do
|
||||||
|
checkUpgrade urlrenderer
|
||||||
|
go h =<< Just <$> liftIO getCurrentTime
|
||||||
|
else go h lastchecked
|
||||||
halfday = 12 * 60 * 60
|
halfday = 12 * 60 * 60
|
||||||
|
|
||||||
checkUpgrade :: UrlRenderer -> Assistant ()
|
checkUpgrade :: UrlRenderer -> Assistant ()
|
||||||
|
|
|
@ -9,6 +9,7 @@ module Types.Distribution where
|
||||||
|
|
||||||
import Types.Key
|
import Types.Key
|
||||||
import Data.Time.Clock
|
import Data.Time.Clock
|
||||||
|
import Git.Config (isTrue, boolConfig)
|
||||||
|
|
||||||
data GitAnnexDistribution = GitAnnexDistribution
|
data GitAnnexDistribution = GitAnnexDistribution
|
||||||
{ distributionUrl :: String
|
{ distributionUrl :: String
|
||||||
|
@ -20,3 +21,18 @@ data GitAnnexDistribution = GitAnnexDistribution
|
||||||
deriving (Read, Show, Eq)
|
deriving (Read, Show, Eq)
|
||||||
|
|
||||||
type GitAnnexVersion = String
|
type GitAnnexVersion = String
|
||||||
|
|
||||||
|
data AutoUpgrade = AskUpgrade | AutoUpgrade | NoAutoUpgrade
|
||||||
|
deriving (Eq)
|
||||||
|
|
||||||
|
toAutoUpgrade :: (Maybe String) -> AutoUpgrade
|
||||||
|
toAutoUpgrade Nothing = AskUpgrade
|
||||||
|
toAutoUpgrade (Just s)
|
||||||
|
| s == "ask" = AskUpgrade
|
||||||
|
| isTrue s == Just True = AutoUpgrade
|
||||||
|
| otherwise = NoAutoUpgrade
|
||||||
|
|
||||||
|
fromAutoUpgrade :: AutoUpgrade -> String
|
||||||
|
fromAutoUpgrade AskUpgrade = "ask"
|
||||||
|
fromAutoUpgrade AutoUpgrade = boolConfig True
|
||||||
|
fromAutoUpgrade NoAutoUpgrade = boolConfig False
|
||||||
|
|
|
@ -17,6 +17,7 @@ import qualified Git
|
||||||
import qualified Git.Config
|
import qualified Git.Config
|
||||||
import Utility.DataUnits
|
import Utility.DataUnits
|
||||||
import Config.Cost
|
import Config.Cost
|
||||||
|
import Types.Distribution
|
||||||
|
|
||||||
{- Main git-annex settings. Each setting corresponds to a git-config key
|
{- Main git-annex settings. Each setting corresponds to a git-config key
|
||||||
- such as annex.foo -}
|
- such as annex.foo -}
|
||||||
|
@ -42,6 +43,7 @@ data GitConfig = GitConfig
|
||||||
, annexCrippledFileSystem :: Bool
|
, annexCrippledFileSystem :: Bool
|
||||||
, annexLargeFiles :: Maybe String
|
, annexLargeFiles :: Maybe String
|
||||||
, annexFsckNudge :: Bool
|
, annexFsckNudge :: Bool
|
||||||
|
, annexAutoUpgrade :: AutoUpgrade
|
||||||
, coreSymlinks :: Bool
|
, coreSymlinks :: Bool
|
||||||
, gcryptId :: Maybe String
|
, gcryptId :: Maybe String
|
||||||
}
|
}
|
||||||
|
@ -70,6 +72,7 @@ extractGitConfig r = GitConfig
|
||||||
, annexCrippledFileSystem = getbool (annex "crippledfilesystem") False
|
, annexCrippledFileSystem = getbool (annex "crippledfilesystem") False
|
||||||
, annexLargeFiles = getmaybe (annex "largefiles")
|
, annexLargeFiles = getmaybe (annex "largefiles")
|
||||||
, annexFsckNudge = getbool (annex "fscknudge") True
|
, annexFsckNudge = getbool (annex "fscknudge") True
|
||||||
|
, annexAutoUpgrade = toAutoUpgrade $ getmaybe (annex "autoupgrade")
|
||||||
, coreSymlinks = getbool "core.symlinks" True
|
, coreSymlinks = getbool "core.symlinks" True
|
||||||
, gcryptId = getmaybe "core.gcrypt-id"
|
, gcryptId = getmaybe "core.gcrypt-id"
|
||||||
}
|
}
|
||||||
|
|
|
@ -544,7 +544,7 @@ subdirectories).
|
||||||
to their local `git-annex` branches. So the forgetfulness will automatically
|
to their local `git-annex` branches. So the forgetfulness will automatically
|
||||||
propigate out from its starting point until all repositories running
|
propigate out from its starting point until all repositories running
|
||||||
git-annex have forgotten their old history. (You may need to force
|
git-annex have forgotten their old history. (You may need to force
|
||||||
git to push the branch to any git repositories not running git-annex.
|
git to push the branch to any git repositories not running git-annex.)
|
||||||
|
|
||||||
* `repair`
|
* `repair`
|
||||||
|
|
||||||
|
@ -1147,6 +1147,21 @@ Here are all the supported configuration settings.
|
||||||
When set to false, prevents the webapp from reminding you when using
|
When set to false, prevents the webapp from reminding you when using
|
||||||
repositories that lack consistency checks.
|
repositories that lack consistency checks.
|
||||||
|
|
||||||
|
* `annex.autoupgrade`
|
||||||
|
|
||||||
|
When set to ask (the default), the webapp will check for new versions
|
||||||
|
and prompt if they should be upgraded to. When set to true, automatically
|
||||||
|
upgrades without prompting (on some supported platforms). When set to
|
||||||
|
false, disables any upgrade checking.
|
||||||
|
|
||||||
|
Note that upgrade checking is only done when git-annex is installed
|
||||||
|
from one of the prebuilt images from its website. This does not
|
||||||
|
bypass eg, a Linux distribution's own upgrade handling code.
|
||||||
|
|
||||||
|
This setting also controls whether to restart the git-annex assistant
|
||||||
|
when the git-annex binary is detected to have changed. That is useful
|
||||||
|
no matter how you installed git-annex.
|
||||||
|
|
||||||
* `annex.autocommit`
|
* `annex.autocommit`
|
||||||
|
|
||||||
Set to false to prevent the git-annex assistant from automatically
|
Set to false to prevent the git-annex assistant from automatically
|
||||||
|
|
Loading…
Reference in a new issue