2014-01-02 00:12:20 +00:00
|
|
|
{- unparsed preferred content expressions
|
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
- Copyright 2012-2014 Joey Hess <id@joeyh.name>
|
2014-01-02 00:12:20 +00:00
|
|
|
-
|
|
|
|
- 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
|
|
|
|
|
2016-01-20 20:36:33 +00:00
|
|
|
import Annex.Common
|
2014-01-02 00:12:20 +00:00
|
|
|
import qualified Annex.Branch
|
|
|
|
import qualified Annex
|
|
|
|
import Logs
|
|
|
|
import Logs.UUIDBased
|
2014-03-15 20:17:01 +00:00
|
|
|
import Logs.MapLog
|
2014-01-02 00:12:20 +00:00
|
|
|
import Types.StandardGroups
|
2014-03-15 20:17:01 +00:00
|
|
|
import Types.Group
|
2014-01-02 00:12:20 +00:00
|
|
|
|
|
|
|
{- Changes the preferred content configuration of a remote. -}
|
|
|
|
preferredContentSet :: UUID -> PreferredContentExpression -> Annex ()
|
2014-03-29 19:20:55 +00:00
|
|
|
preferredContentSet = setLog preferredContentLog
|
|
|
|
|
|
|
|
requiredContentSet :: UUID -> PreferredContentExpression -> Annex ()
|
|
|
|
requiredContentSet = setLog requiredContentLog
|
|
|
|
|
|
|
|
setLog :: FilePath -> UUID -> PreferredContentExpression -> Annex ()
|
|
|
|
setLog logfile uuid@(UUID _) val = do
|
2014-01-02 00:12:20 +00:00
|
|
|
ts <- liftIO getPOSIXTime
|
2014-03-29 19:20:55 +00:00
|
|
|
Annex.Branch.change logfile $
|
2014-03-15 20:17:01 +00:00
|
|
|
showLog id
|
|
|
|
. changeLog ts uuid val
|
|
|
|
. parseLog Just
|
2014-03-29 19:20:55 +00:00
|
|
|
Annex.changeState $ \s -> s
|
|
|
|
{ Annex.preferredcontentmap = Nothing
|
|
|
|
, Annex.requiredcontentmap = Nothing
|
|
|
|
}
|
|
|
|
setLog _ NoUUID _ = error "unknown UUID; cannot modify"
|
2014-01-02 00:12:20 +00:00
|
|
|
|
2014-03-15 20:17:01 +00:00
|
|
|
{- Changes the preferred content configuration of a group. -}
|
|
|
|
groupPreferredContentSet :: Group -> PreferredContentExpression -> Annex ()
|
|
|
|
groupPreferredContentSet g val = do
|
|
|
|
ts <- liftIO getPOSIXTime
|
|
|
|
Annex.Branch.change groupPreferredContentLog $
|
|
|
|
showMapLog id id
|
|
|
|
. changeMapLog ts g val
|
|
|
|
. parseMapLog Just Just
|
|
|
|
Annex.changeState $ \s -> s { Annex.preferredcontentmap = Nothing }
|
|
|
|
|
2014-01-02 00:12:20 +00:00
|
|
|
preferredContentMapRaw :: Annex (M.Map UUID PreferredContentExpression)
|
|
|
|
preferredContentMapRaw = simpleMap . parseLog Just
|
|
|
|
<$> Annex.Branch.get preferredContentLog
|
2014-03-15 20:17:01 +00:00
|
|
|
|
2014-03-29 19:20:55 +00:00
|
|
|
requiredContentMapRaw :: Annex (M.Map UUID PreferredContentExpression)
|
|
|
|
requiredContentMapRaw = simpleMap . parseLog Just
|
|
|
|
<$> Annex.Branch.get requiredContentLog
|
|
|
|
|
2014-03-15 20:17:01 +00:00
|
|
|
groupPreferredContentMapRaw :: Annex (M.Map Group PreferredContentExpression)
|
|
|
|
groupPreferredContentMapRaw = simpleMap . parseMapLog Just Just
|
|
|
|
<$> Annex.Branch.get groupPreferredContentLog
|