This commit is contained in:
Joey Hess 2012-10-01 15:17:21 -04:00
parent 2a96b1aab3
commit 5bd5bc094a
3 changed files with 11 additions and 11 deletions

View file

@ -30,6 +30,5 @@ start _ = error "Specify a repository and a group."
perform :: UUID -> Group -> CommandPerform perform :: UUID -> Group -> CommandPerform
perform uuid g = do perform uuid g = do
s <- lookupGroups uuid groupChange uuid (S.insert g)
groupSet uuid (S.insert g s)
next $ return True next $ return True

View file

@ -30,6 +30,5 @@ start _ = error "Specify a repository and a group."
perform :: UUID -> Group -> CommandPerform perform :: UUID -> Group -> CommandPerform
perform uuid g = do perform uuid g = do
s <- lookupGroups uuid groupChange uuid (S.delete g)
groupSet uuid (S.delete g s)
next $ return True next $ return True

View file

@ -6,7 +6,7 @@
-} -}
module Logs.Group ( module Logs.Group (
groupSet, groupChange,
lookupGroups, lookupGroups,
groupMap, groupMap,
) where ) where
@ -29,15 +29,17 @@ groupLog = "group.log"
lookupGroups :: UUID -> Annex (S.Set Group) lookupGroups :: UUID -> Annex (S.Set Group)
lookupGroups u = (fromMaybe S.empty . M.lookup u) <$> groupMap lookupGroups u = (fromMaybe S.empty . M.lookup u) <$> groupMap
{- Changes the groups for a uuid in the groupLog. -} {- Applies a set modifier to change the groups for a uuid in the groupLog. -}
groupSet :: UUID -> S.Set Group -> Annex () groupChange :: UUID -> (S.Set Group -> S.Set Group) -> Annex ()
groupSet uuid@(UUID _) groups = do groupChange uuid@(UUID _) modifier = do
curr <- lookupGroups uuid
ts <- liftIO getPOSIXTime ts <- liftIO getPOSIXTime
Annex.Branch.change groupLog $ Annex.Branch.change groupLog $
showLog (unwords . S.toList) . changeLog ts uuid groups . showLog (unwords . S.toList) .
parseLog (Just . S.fromList . words) changeLog ts uuid (modifier curr) .
parseLog (Just . S.fromList . words)
Annex.changeState $ \s -> s { Annex.groupmap = Nothing } 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. -} {- Read the groupLog into a map. The map is cached for speed. -}
groupMap :: Annex GroupMap groupMap :: Annex GroupMap