summaryrefslogtreecommitdiff
path: root/Logs/PreferredContent/Raw.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-03-29 15:20:55 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-03-29 16:03:33 -0400
commit926c83c21804f90922154edfdafc5d9f64c9bb44 (patch)
treef87101cdaba064a229940e448a241da012bf2b89 /Logs/PreferredContent/Raw.hs
parentbcc838aacd3a32973e20b68f235c15d4b7cd561f (diff)
Added required content configuration.
This includes checking when dropping files that any required content configuration is satisfied. However, it does not yet include an active check on the required content; the location log is trusted when checking the required content expression.
Diffstat (limited to 'Logs/PreferredContent/Raw.hs')
-rw-r--r--Logs/PreferredContent/Raw.hs21
1 files changed, 17 insertions, 4 deletions
diff --git a/Logs/PreferredContent/Raw.hs b/Logs/PreferredContent/Raw.hs
index ce91c2dcd..bbf5a1edc 100644
--- a/Logs/PreferredContent/Raw.hs
+++ b/Logs/PreferredContent/Raw.hs
@@ -21,14 +21,23 @@ import Types.Group
{- Changes the preferred content configuration of a remote. -}
preferredContentSet :: UUID -> PreferredContentExpression -> Annex ()
-preferredContentSet uuid@(UUID _) val = do
+preferredContentSet = setLog preferredContentLog
+
+requiredContentSet :: UUID -> PreferredContentExpression -> Annex ()
+requiredContentSet = setLog requiredContentLog
+
+setLog :: FilePath -> UUID -> PreferredContentExpression -> Annex ()
+setLog logfile uuid@(UUID _) val = do
ts <- liftIO getPOSIXTime
- Annex.Branch.change preferredContentLog $
+ Annex.Branch.change logfile $
showLog id
. changeLog ts uuid val
. parseLog Just
- Annex.changeState $ \s -> s { Annex.preferredcontentmap = Nothing }
-preferredContentSet NoUUID _ = error "unknown UUID; cannot modify"
+ Annex.changeState $ \s -> s
+ { Annex.preferredcontentmap = Nothing
+ , Annex.requiredcontentmap = Nothing
+ }
+setLog _ NoUUID _ = error "unknown UUID; cannot modify"
{- Changes the preferred content configuration of a group. -}
groupPreferredContentSet :: Group -> PreferredContentExpression -> Annex ()
@@ -44,6 +53,10 @@ preferredContentMapRaw :: Annex (M.Map UUID PreferredContentExpression)
preferredContentMapRaw = simpleMap . parseLog Just
<$> Annex.Branch.get preferredContentLog
+requiredContentMapRaw :: Annex (M.Map UUID PreferredContentExpression)
+requiredContentMapRaw = simpleMap . parseLog Just
+ <$> Annex.Branch.get requiredContentLog
+
groupPreferredContentMapRaw :: Annex (M.Map Group PreferredContentExpression)
groupPreferredContentMapRaw = simpleMap . parseMapLog Just Just
<$> Annex.Branch.get groupPreferredContentLog