diff options
-rw-r--r-- | Annex/UUID.hs | 16 | ||||
-rw-r--r-- | Types/GitConfig.hs | 3 |
2 files changed, 14 insertions, 5 deletions
diff --git a/Annex/UUID.hs b/Annex/UUID.hs index 69d4ab6c4..1e80d6fe1 100644 --- a/Annex/UUID.hs +++ b/Annex/UUID.hs @@ -6,7 +6,7 @@ - UUIDs of remotes are cached in git config, using keys named - remote.<name>.annex-uuid - - - Copyright 2010-2013 Joey Hess <id@joeyh.name> + - Copyright 2010-2016 Joey Hess <id@joeyh.name> - - Licensed under the GNU GPL version 3 or higher. -} @@ -29,6 +29,7 @@ module Annex.UUID ( ) where import Annex.Common +import qualified Annex import qualified Git import qualified Git.Config import Config @@ -58,9 +59,10 @@ gCryptNameSpace = U5.generateNamed U5.namespaceURL $ {- Get current repository's UUID. -} getUUID :: Annex UUID -getUUID = getRepoUUID =<< gitRepo +getUUID = annexUUID <$> Annex.getGitConfig -{- Looks up a repo's UUID, caching it in .git/config if it's not already. -} +{- Looks up a remote repo's UUID, caching it in .git/config if + - it's not already. -} getRepoUUID :: Git.Repo -> Annex UUID getRepoUUID r = do c <- toUUID <$> getConfig cachekey "" @@ -78,7 +80,9 @@ getRepoUUID r = do cachekey = remoteConfig r "uuid" removeRepoUUID :: Annex () -removeRepoUUID = unsetConfig configkey +removeRepoUUID = do + unsetConfig configkey + storeUUID NoUUID getUncachedUUID :: Git.Repo -> UUID getUncachedUUID = toUUID . Git.Config.get key "" @@ -98,7 +102,9 @@ prepUUID = whenM ((==) NoUUID <$> getUUID) $ storeUUID =<< liftIO genUUID storeUUID :: UUID -> Annex () -storeUUID = storeUUIDIn configkey +storeUUID u = do + Annex.changeGitConfig $ \c -> c { annexUUID = u } + storeUUIDIn configkey u storeUUIDIn :: ConfigKey -> UUID -> Annex () storeUUIDIn configfield = setConfig configfield . fromUUID diff --git a/Types/GitConfig.hs b/Types/GitConfig.hs index 0f2e1eaf2..208da4ac7 100644 --- a/Types/GitConfig.hs +++ b/Types/GitConfig.hs @@ -19,6 +19,7 @@ import qualified Git.Construct import Git.SharedRepository import Utility.DataUnits import Config.Cost +import Types.UUID import Types.Distribution import Types.Availability import Types.NumCopies @@ -32,6 +33,7 @@ import Utility.ThreadScheduler (Seconds(..)) - such as annex.foo -} data GitConfig = GitConfig { annexVersion :: Maybe String + , annexUUID :: UUID , annexNumCopies :: Maybe NumCopies , annexDiskReserve :: Integer , annexDirect :: Bool @@ -75,6 +77,7 @@ data GitConfig = GitConfig extractGitConfig :: Git.Repo -> GitConfig extractGitConfig r = GitConfig { annexVersion = notempty $ getmaybe (annex "version") + , annexUUID = maybe NoUUID toUUID $ getmaybe (annex "uuid") , annexNumCopies = NumCopies <$> getmayberead (annex "numcopies") , annexDiskReserve = fromMaybe onemegabyte $ readSize dataUnits =<< getmaybe (annex "diskreserve") |