improve data type

This commit is contained in:
Joey Hess 2016-01-01 15:56:24 -04:00
parent f7256842cc
commit ec28151722
Failed to extract signature
5 changed files with 8 additions and 7 deletions

View file

@ -20,6 +20,7 @@ import Logs.Group
import Logs.NumCopies import Logs.NumCopies
import Remote.List (remoteListRefresh) import Remote.List (remoteListRefresh)
import qualified Git.LsTree as LsTree import qualified Git.LsTree as LsTree
import Git.Types
import Git.FilePath import Git.FilePath
import qualified Annex.Branch import qualified Annex.Branch
@ -51,7 +52,7 @@ configMonitorThread = namedThread "ConfigMonitor" $ loop =<< getConfigs
loop new loop new
{- Config files, and their checksums. -} {- Config files, and their checksums. -}
type Configs = S.Set (FilePath, String) type Configs = S.Set (FilePath, Sha)
{- All git-annex's config files, and actions to run when they change. -} {- All git-annex's config files, and actions to run when they change. -}
configFilesActions :: [(FilePath, Assistant ())] configFilesActions :: [(FilePath, Assistant ())]

View file

@ -80,7 +80,7 @@ withFilesInRefs a = mapM_ go
(l, cleanup) <- inRepo $ LsTree.lsTree (Git.Ref r) (l, cleanup) <- inRepo $ LsTree.lsTree (Git.Ref r)
forM_ l $ \i -> do forM_ l $ \i -> do
let f = getTopFilePath $ LsTree.file i let f = getTopFilePath $ LsTree.file i
v <- catKey (Git.Ref $ LsTree.sha i) v <- catKey (LsTree.sha i)
case v of case v of
Nothing -> noop Nothing -> noop
Just k -> whenM (matcher $ MatchingKey k) $ Just k -> whenM (matcher $ MatchingKey k) $

View file

@ -221,7 +221,7 @@ scanAssociatedFiles = whenM (isJust <$> inRepo Git.Branch.current) $
forM_ l $ \i -> forM_ l $ \i ->
when (isregfile i) $ when (isregfile i) $
maybe noop (add h i) maybe noop (add h i)
=<< catKey (Git.Types.Ref $ Git.LsTree.sha i) =<< catKey (Git.LsTree.sha i)
liftIO $ void cleanup liftIO $ void cleanup
where where
dropallassociated = queueDb $ dropallassociated = queueDb $

View file

@ -26,7 +26,7 @@ import System.Posix.Types
data TreeItem = TreeItem data TreeItem = TreeItem
{ mode :: FileMode { mode :: FileMode
, typeobj :: String , typeobj :: String
, sha :: String , sha :: Ref
, file :: TopFilePath , file :: TopFilePath
} deriving Show } deriving Show
@ -66,7 +66,7 @@ parseLsTree :: String -> TreeItem
parseLsTree l = TreeItem parseLsTree l = TreeItem
{ mode = fst $ Prelude.head $ readOct m { mode = fst $ Prelude.head $ readOct m
, typeobj = t , typeobj = t
, sha = s , sha = Ref s
, file = asTopFilePath $ Git.Filename.decode f , file = asTopFilePath $ Git.Filename.decode f
} }
where where

View file

@ -342,8 +342,8 @@ verifyTree missing treesha r
| S.member treesha missing = return False | S.member treesha missing = return False
| otherwise = do | otherwise = do
(ls, cleanup) <- pipeNullSplit (LsTree.lsTreeParams treesha []) r (ls, cleanup) <- pipeNullSplit (LsTree.lsTreeParams treesha []) r
let objshas = map (extractSha . LsTree.sha . LsTree.parseLsTree) ls let objshas = map (LsTree.sha . LsTree.parseLsTree) ls
if any isNothing objshas || any (`S.member` missing) (catMaybes objshas) if any (`S.member` missing) objshas
then do then do
void cleanup void cleanup
return False return False