From ec28151722c680cb5bbc2c00efe0b153ac9bcdf9 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 1 Jan 2016 15:56:24 -0400 Subject: [PATCH] improve data type --- Assistant/Threads/ConfigMonitor.hs | 3 ++- CmdLine/Seek.hs | 2 +- Database/Keys.hs | 2 +- Git/LsTree.hs | 4 ++-- Git/Repair.hs | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Assistant/Threads/ConfigMonitor.hs b/Assistant/Threads/ConfigMonitor.hs index 7ab55fb82a..d63faff5e9 100644 --- a/Assistant/Threads/ConfigMonitor.hs +++ b/Assistant/Threads/ConfigMonitor.hs @@ -20,6 +20,7 @@ import Logs.Group import Logs.NumCopies import Remote.List (remoteListRefresh) import qualified Git.LsTree as LsTree +import Git.Types import Git.FilePath import qualified Annex.Branch @@ -51,7 +52,7 @@ configMonitorThread = namedThread "ConfigMonitor" $ loop =<< getConfigs loop new {- 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. -} configFilesActions :: [(FilePath, Assistant ())] diff --git a/CmdLine/Seek.hs b/CmdLine/Seek.hs index cb7faebac9..be2bd22c30 100644 --- a/CmdLine/Seek.hs +++ b/CmdLine/Seek.hs @@ -80,7 +80,7 @@ withFilesInRefs a = mapM_ go (l, cleanup) <- inRepo $ LsTree.lsTree (Git.Ref r) forM_ l $ \i -> do let f = getTopFilePath $ LsTree.file i - v <- catKey (Git.Ref $ LsTree.sha i) + v <- catKey (LsTree.sha i) case v of Nothing -> noop Just k -> whenM (matcher $ MatchingKey k) $ diff --git a/Database/Keys.hs b/Database/Keys.hs index 7a844b5b02..aeb71ecdeb 100644 --- a/Database/Keys.hs +++ b/Database/Keys.hs @@ -221,7 +221,7 @@ scanAssociatedFiles = whenM (isJust <$> inRepo Git.Branch.current) $ forM_ l $ \i -> when (isregfile i) $ maybe noop (add h i) - =<< catKey (Git.Types.Ref $ Git.LsTree.sha i) + =<< catKey (Git.LsTree.sha i) liftIO $ void cleanup where dropallassociated = queueDb $ diff --git a/Git/LsTree.hs b/Git/LsTree.hs index 13f3e4bcd9..b1d9190d0f 100644 --- a/Git/LsTree.hs +++ b/Git/LsTree.hs @@ -26,7 +26,7 @@ import System.Posix.Types data TreeItem = TreeItem { mode :: FileMode , typeobj :: String - , sha :: String + , sha :: Ref , file :: TopFilePath } deriving Show @@ -66,7 +66,7 @@ parseLsTree :: String -> TreeItem parseLsTree l = TreeItem { mode = fst $ Prelude.head $ readOct m , typeobj = t - , sha = s + , sha = Ref s , file = asTopFilePath $ Git.Filename.decode f } where diff --git a/Git/Repair.hs b/Git/Repair.hs index b441f13379..fcfc03600c 100644 --- a/Git/Repair.hs +++ b/Git/Repair.hs @@ -342,8 +342,8 @@ verifyTree missing treesha r | S.member treesha missing = return False | otherwise = do (ls, cleanup) <- pipeNullSplit (LsTree.lsTreeParams treesha []) r - let objshas = map (extractSha . LsTree.sha . LsTree.parseLsTree) ls - if any isNothing objshas || any (`S.member` missing) (catMaybes objshas) + let objshas = map (LsTree.sha . LsTree.parseLsTree) ls + if any (`S.member` missing) objshas then do void cleanup return False