Preferred content path matching bugfix.

When in a subdir, both the normal filepath, and the filepath relative to
the top of the git repo are needed for matching. The former for key lookup,
and the latter for include/exclude to match against. Previously, key lookup
didn't work in this situation.
This commit is contained in:
Joey Hess 2012-10-17 16:01:09 -04:00
parent 59170c4187
commit e7780a39f5
6 changed files with 37 additions and 29 deletions

View file

@ -9,7 +9,6 @@ module Annex.Wanted where
import Common.Annex
import Logs.PreferredContent
import Git.FilePath
import Annex.UUID
import Types.Remote
@ -18,22 +17,17 @@ import qualified Data.Set as S
{- Check if a file is preferred content for the local repository. -}
wantGet :: AssociatedFile -> Annex Bool
wantGet Nothing = return True
wantGet (Just file) = do
fp <- inRepo $ toTopFilePath file
isPreferredContent Nothing S.empty fp
wantGet (Just file) = isPreferredContent Nothing S.empty file
{- Check if a file is preferred content for a remote. -}
wantSend :: AssociatedFile -> UUID -> Annex Bool
wantSend Nothing _ = return True
wantSend (Just file) to = do
fp <- inRepo $ toTopFilePath file
isPreferredContent (Just to) S.empty fp
wantSend (Just file) to = isPreferredContent (Just to) S.empty file
{- Check if a file can be dropped, maybe from a remote.
- Don't drop files that are preferred content. -}
wantDrop :: Maybe UUID -> AssociatedFile -> Annex Bool
wantDrop _ Nothing = return True
wantDrop from (Just file) = do
fp <- inRepo $ toTopFilePath file
u <- maybe getUUID (return . id) from
not <$> isPreferredContent (Just u) (S.singleton u) fp
not <$> isPreferredContent (Just u) (S.singleton u) file