diff options
author | Joey Hess <joey@kitenet.net> | 2012-10-01 15:17:21 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-10-01 15:17:21 -0400 |
commit | 041242f735a20027acfef10764398c208dc94183 (patch) | |
tree | d2ad39f9ccfe85d0cc230ad6c43403c243339416 /Logs/Group.hs | |
parent | 59d2f363b7a2762978978bb3edf62aa47ef81abd (diff) |
simplify
Diffstat (limited to 'Logs/Group.hs')
-rw-r--r-- | Logs/Group.hs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Logs/Group.hs b/Logs/Group.hs index 9263c7760..f701c5270 100644 --- a/Logs/Group.hs +++ b/Logs/Group.hs @@ -6,7 +6,7 @@ -} module Logs.Group ( - groupSet, + groupChange, lookupGroups, groupMap, ) where @@ -29,15 +29,17 @@ groupLog = "group.log" lookupGroups :: UUID -> Annex (S.Set Group) lookupGroups u = (fromMaybe S.empty . M.lookup u) <$> groupMap -{- Changes the groups for a uuid in the groupLog. -} -groupSet :: UUID -> S.Set Group -> Annex () -groupSet uuid@(UUID _) groups = do +{- Applies a set modifier to change the groups for a uuid in the groupLog. -} +groupChange :: UUID -> (S.Set Group -> S.Set Group) -> Annex () +groupChange uuid@(UUID _) modifier = do + curr <- lookupGroups uuid ts <- liftIO getPOSIXTime Annex.Branch.change groupLog $ - showLog (unwords . S.toList) . changeLog ts uuid groups . - parseLog (Just . S.fromList . words) + showLog (unwords . S.toList) . + changeLog ts uuid (modifier curr) . + parseLog (Just . S.fromList . words) Annex.changeState $ \s -> s { Annex.groupmap = Nothing } -groupSet NoUUID _ = error "unknown UUID; cannot modify group" +groupChange NoUUID _ = error "unknown UUID; cannot modify group" {- Read the groupLog into a map. The map is cached for speed. -} groupMap :: Annex GroupMap |