diff options
author | Joey Hess <joey@kitenet.net> | 2014-01-01 20:12:20 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-01-01 20:12:20 -0400 |
commit | 08b48fa3ee2cb817b41c56470be8cf6c3cee7f27 (patch) | |
tree | 3e01c1d3a781320e7794374f7bb4fb94c87bc000 /Logs | |
parent | a62d941be1e90d13d4dddbe86d75c050f22cd61d (diff) |
added GETWANTED, SETWANTED for Tobias's flickr remote
This was unexpectedly difficult because of a depdenency cycle. To parse a
preferred content expression involves several things that need to operate
on the list of remotes. Which needs Remote.External. The only way to avoid
this cycle (I tried breaking it at several points) was to skip parsing the
expression in SETWANTED.
That's sorta ok, because git-annex already has to deal with unparsable
preferred content expressions being stored, in order to handle eg,
upgrades. But I'm still not very happy that I cannot check it.
I feel this is a strong indication that I need to beware of further
bloating the special remote protocol interface.
Diffstat (limited to 'Logs')
-rw-r--r-- | Logs/PreferredContent.hs | 15 | ||||
-rw-r--r-- | Logs/PreferredContent/Raw.hs | 31 |
2 files changed, 32 insertions, 14 deletions
diff --git a/Logs/PreferredContent.hs b/Logs/PreferredContent.hs index 26eaaaece..2a9aed36b 100644 --- a/Logs/PreferredContent.hs +++ b/Logs/PreferredContent.hs @@ -19,9 +19,9 @@ module Logs.PreferredContent ( import qualified Data.Map as M import qualified Data.Set as S import Data.Either -import Data.Time.Clock.POSIX import Common.Annex +import Logs.PreferredContent.Raw import qualified Annex.Branch import qualified Annex import Logs @@ -36,15 +36,6 @@ import Logs.Group import Logs.Remote import Types.StandardGroups -{- Changes the preferred content configuration of a remote. -} -preferredContentSet :: UUID -> PreferredContentExpression -> Annex () -preferredContentSet uuid@(UUID _) val = do - ts <- liftIO getPOSIXTime - Annex.Branch.change preferredContentLog $ - showLog id . changeLog ts uuid val . parseLog Just - Annex.changeState $ \s -> s { Annex.preferredcontentmap = Nothing } -preferredContentSet NoUUID _ = error "unknown UUID; cannot modify" - {- Checks if a file is preferred content for the specified repository - (or the current repository if none is specified). -} isPreferredContent :: Maybe UUID -> AssumeNotPresent -> FilePath -> Bool -> Annex Bool @@ -71,10 +62,6 @@ preferredContentMapLoad = do Annex.changeState $ \s -> s { Annex.preferredcontentmap = Just m } return m -preferredContentMapRaw :: Annex (M.Map UUID PreferredContentExpression) -preferredContentMapRaw = simpleMap . parseLog Just - <$> Annex.Branch.get preferredContentLog - {- This intentionally never fails, even on unparsable expressions, - because the configuration is shared among repositories and newer - versions of git-annex may add new features. Instead, parse errors diff --git a/Logs/PreferredContent/Raw.hs b/Logs/PreferredContent/Raw.hs new file mode 100644 index 000000000..63f6118e4 --- /dev/null +++ b/Logs/PreferredContent/Raw.hs @@ -0,0 +1,31 @@ +{- unparsed preferred content expressions + - + - Copyright 2012 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Logs.PreferredContent.Raw where + +import qualified Data.Map as M +import Data.Time.Clock.POSIX + +import Common.Annex +import qualified Annex.Branch +import qualified Annex +import Logs +import Logs.UUIDBased +import Types.StandardGroups + +{- Changes the preferred content configuration of a remote. -} +preferredContentSet :: UUID -> PreferredContentExpression -> Annex () +preferredContentSet uuid@(UUID _) val = do + ts <- liftIO getPOSIXTime + Annex.Branch.change preferredContentLog $ + showLog id . changeLog ts uuid val . parseLog Just + Annex.changeState $ \s -> s { Annex.preferredcontentmap = Nothing } +preferredContentSet NoUUID _ = error "unknown UUID; cannot modify" + +preferredContentMapRaw :: Annex (M.Map UUID PreferredContentExpression) +preferredContentMapRaw = simpleMap . parseLog Just + <$> Annex.Branch.get preferredContentLog |