2013-10-28 18:50:17 +00:00
|
|
|
{- git-annex checking whether content is wanted
|
2012-10-08 20:06:56 +00:00
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
- Copyright 2012 Joey Hess <id@joeyh.name>
|
2012-10-08 20:06:56 +00:00
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Annex.Wanted where
|
|
|
|
|
2016-01-20 20:36:33 +00:00
|
|
|
import Annex.Common
|
2012-10-08 20:06:56 +00:00
|
|
|
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. -}
|
2014-01-23 20:37:08 +00:00
|
|
|
wantGet :: Bool -> Maybe Key -> AssociatedFile -> Annex Bool
|
2015-01-28 20:11:28 +00:00
|
|
|
wantGet d key file = isPreferredContent Nothing S.empty key file d
|
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. -}
|
2014-01-23 20:37:08 +00:00
|
|
|
wantSend :: Bool -> Maybe Key -> AssociatedFile -> UUID -> Annex Bool
|
2015-01-28 20:11:28 +00:00
|
|
|
wantSend d key file to = isPreferredContent (Just to) S.empty key file d
|
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. -}
|
2014-01-23 20:37:08 +00:00
|
|
|
wantDrop :: Bool -> Maybe UUID -> Maybe Key -> AssociatedFile -> Annex Bool
|
2015-01-28 20:11:28 +00:00
|
|
|
wantDrop d from key file = do
|
2012-10-08 21:14:01 +00:00
|
|
|
u <- maybe getUUID (return . id) from
|
2015-01-28 20:11:28 +00:00
|
|
|
not <$> isPreferredContent (Just u) (S.singleton u) key file d
|