diff options
author | Joey Hess <joey@kitenet.net> | 2012-01-10 15:36:54 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-01-11 00:06:54 -0400 |
commit | abdacf58ed5d0da0439819feb669b04b2368bb92 (patch) | |
tree | 77694958b647c8015104d1d8151a744a03666070 /Seek.hs | |
parent | 16e7178f207b0472346c06f30aa210cebe373c36 (diff) |
tweaks
Diffstat (limited to 'Seek.hs')
-rw-r--r-- | Seek.hs | 17 |
1 files changed, 4 insertions, 13 deletions
@@ -23,9 +23,7 @@ import qualified Limit import qualified Option seekHelper :: ([FilePath] -> Git.Repo -> IO [FilePath]) -> [FilePath] -> Annex [FilePath] -seekHelper a params = do - g <- gitRepo - liftIO $ runPreserveOrder (`a` g) params +seekHelper a params = inRepo $ \g -> runPreserveOrder (`a` g) params withFilesInGit :: (FilePath -> CommandStart) -> CommandSeek withFilesInGit a params = prepFiltered a $ seekHelper LsFiles.inRepo params @@ -41,9 +39,8 @@ withNumCopies a params = withAttrFilesInGit "annex.numcopies" go params go (file, v) = a (readMaybe v) file withBackendFilesInGit :: (BackendFile -> CommandStart) -> CommandSeek -withBackendFilesInGit a params = do - files <- seekHelper LsFiles.inRepo params - prepBackendPairs a files +withBackendFilesInGit a params = + prepBackendPairs a =<< seekHelper LsFiles.inRepo params withFilesNotInGit :: (BackendFile -> CommandStart) -> CommandSeek withFilesNotInGit a params = do @@ -118,18 +115,12 @@ prepBackendPairs a fs = prepFilteredGen a snd (chooseBackends fs) prepFilteredGen :: (b -> CommandStart) -> (b -> FilePath) -> Annex [b] -> Annex [CommandStart] prepFilteredGen a d fs = do matcher <- Limit.getMatcher - prepStart (proc matcher) fs + map (proc matcher) <$> fs where proc matcher v = do let f = d v ok <- matcher f if ok then a v else return Nothing -{- Generates a list of CommandStart actions that will be run to perform a - - command, using a list (ie of files) coming from an action. The list - - will be produced and consumed lazily. -} -prepStart :: (b -> CommandStart) -> Annex [b] -> Annex [CommandStart] -prepStart a = liftM (map a) - notSymlink :: FilePath -> IO Bool notSymlink f = liftIO $ not . isSymbolicLink <$> getSymbolicLinkStatus f |