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
|
|
|
|
|
|
|
|
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. -}
|
2012-12-06 17:22:16 +00:00
|
|
|
wantGet :: Bool -> AssociatedFile -> Annex Bool
|
|
|
|
wantGet def Nothing = return def
|
|
|
|
wantGet def (Just file) = isPreferredContent Nothing S.empty file def
|
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-12-06 17:22:16 +00:00
|
|
|
wantSend :: Bool -> AssociatedFile -> UUID -> Annex Bool
|
|
|
|
wantSend def Nothing _ = return def
|
|
|
|
wantSend def (Just file) to = isPreferredContent (Just to) S.empty file def
|
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. -}
|
2012-12-06 17:22:16 +00:00
|
|
|
wantDrop :: Bool -> Maybe UUID -> AssociatedFile -> Annex Bool
|
|
|
|
wantDrop def _ Nothing = return $ not def
|
|
|
|
wantDrop def from (Just file) = do
|
2012-10-08 21:14:01 +00:00
|
|
|
u <- maybe getUUID (return . id) from
|
2012-12-06 17:22:16 +00:00
|
|
|
not <$> isPreferredContent (Just u) (S.singleton u) file def
|