2012-10-08 20:06:56 +00:00
|
|
|
{- git-annex control over whether content is wanted
|
|
|
|
-
|
|
|
|
- Copyright 2012 Joey Hess <joey@kitenet.net>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Annex.Wanted where
|
|
|
|
|
|
|
|
import Common.Annex
|
|
|
|
import Logs.PreferredContent
|
|
|
|
import Annex.UUID
|
2012-10-08 21:14:01 +00:00
|
|
|
import Types.Remote
|
2012-10-08 20:06:56 +00:00
|
|
|
|
|
|
|
import qualified Data.Set as S
|
|
|
|
|
2012-10-08 21:14:01 +00:00
|
|
|
{- Check if a file is preferred content for the local repository. -}
|
|
|
|
wantGet :: AssociatedFile -> Annex Bool
|
|
|
|
wantGet Nothing = return True
|
2012-10-17 20:01:09 +00:00
|
|
|
wantGet (Just file) = isPreferredContent Nothing S.empty file
|
2012-10-08 20:06:56 +00:00
|
|
|
|
2012-10-08 21:14:01 +00:00
|
|
|
{- Check if a file is preferred content for a remote. -}
|
2012-10-09 16:18:41 +00:00
|
|
|
wantSend :: AssociatedFile -> UUID -> Annex Bool
|
|
|
|
wantSend Nothing _ = return True
|
2012-10-17 20:01:09 +00:00
|
|
|
wantSend (Just file) to = isPreferredContent (Just to) S.empty file
|
2012-10-08 20:06:56 +00:00
|
|
|
|
2012-10-08 21:14:01 +00:00
|
|
|
{- 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
|
|
|
|
u <- maybe getUUID (return . id) from
|
2012-10-17 20:01:09 +00:00
|
|
|
not <$> isPreferredContent (Just u) (S.singleton u) file
|