aboutsummaryrefslogtreecommitdiff
path: root/Logs/PreferredContent.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-12-06 13:22:16 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-12-06 13:22:16 -0400
commit2a04e215e10469ee3bab5d1a5d6d76b0c35cc46c (patch)
tree41328caa30ae494316d20e1a5e5909b29aa94516 /Logs/PreferredContent.hs
parent53304252ca5483ce80f5a66bb74cc9f0732f65d7 (diff)
--auto fixes
* get/copy --auto: Transfer data even if it would exceed numcopies, when preferred content settings want it. * drop --auto: Fix dropping content when there are no preferred content settings.
Diffstat (limited to 'Logs/PreferredContent.hs')
-rw-r--r--Logs/PreferredContent.hs12
1 files changed, 7 insertions, 5 deletions
diff --git a/Logs/PreferredContent.hs b/Logs/PreferredContent.hs
index ddcc2acf8..e0eb140b1 100644
--- a/Logs/PreferredContent.hs
+++ b/Logs/PreferredContent.hs
@@ -48,8 +48,8 @@ preferredContentSet NoUUID _ = error "unknown UUID; cannot modify"
{- Checks if a file is preferred content for the specified repository
- (or the current repository if none is specified). -}
-isPreferredContent :: Maybe UUID -> AssumeNotPresent -> FilePath -> Annex Bool
-isPreferredContent mu notpresent file = do
+isPreferredContent :: Maybe UUID -> AssumeNotPresent -> FilePath -> Bool -> Annex Bool
+isPreferredContent mu notpresent file def = do
matchfile <- getTopFilePath <$> inRepo (toTopFilePath file)
let fi = Annex.FileInfo
{ Annex.matchFile = matchfile
@@ -58,9 +58,11 @@ isPreferredContent mu notpresent file = do
u <- maybe getUUID return mu
m <- preferredContentMap
case M.lookup u m of
- Nothing -> return True
- Just matcher -> Utility.Matcher.matchMrun matcher $ \a ->
- a notpresent fi
+ Nothing -> return def
+ Just matcher
+ | Utility.Matcher.isEmpty matcher -> return def
+ | otherwise -> Utility.Matcher.matchMrun matcher $
+ \a -> a notpresent fi
{- The map is cached for speed. -}
preferredContentMap :: Annex Annex.PreferredContentMap