2013-10-28 18:50:17 +00:00
|
|
|
{- git-annex limits by wanted status
|
|
|
|
-
|
2020-09-24 21:59:05 +00:00
|
|
|
- Copyright 2012-2020 Joey Hess <id@joeyh.name>
|
2013-10-28 18:50:17 +00:00
|
|
|
-
|
2019-03-13 19:48:14 +00:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2013-10-28 18:50:17 +00:00
|
|
|
-}
|
|
|
|
|
|
|
|
module Limit.Wanted where
|
|
|
|
|
2016-01-20 20:36:33 +00:00
|
|
|
import Annex.Common
|
2013-10-28 18:50:17 +00:00
|
|
|
import Annex.Wanted
|
|
|
|
import Limit
|
|
|
|
import Types.FileMatcher
|
2020-09-24 21:59:05 +00:00
|
|
|
import Logs.PreferredContent
|
2022-07-28 17:26:03 +00:00
|
|
|
import qualified Remote
|
2013-10-28 18:50:17 +00:00
|
|
|
|
|
|
|
addWantGet :: Annex ()
|
2023-07-25 20:11:06 +00:00
|
|
|
addWantGet = addPreferredContentLimit "want-get" $
|
2020-09-24 21:59:05 +00:00
|
|
|
checkWant $ wantGet False Nothing
|
2013-10-28 18:50:17 +00:00
|
|
|
|
2022-07-28 17:26:03 +00:00
|
|
|
addWantGetBy :: String -> Annex ()
|
|
|
|
addWantGetBy name = do
|
|
|
|
u <- Remote.nameToUUID name
|
2023-07-25 20:11:06 +00:00
|
|
|
addPreferredContentLimit "want-get-by" $ checkWant $ \af ->
|
2022-07-28 17:26:03 +00:00
|
|
|
wantGetBy False Nothing af u
|
|
|
|
|
2013-10-28 18:50:17 +00:00
|
|
|
addWantDrop :: Annex ()
|
2023-07-25 20:11:06 +00:00
|
|
|
addWantDrop = addPreferredContentLimit "want-drop" $ checkWant $ \af ->
|
2022-07-28 17:26:03 +00:00
|
|
|
wantDrop False Nothing Nothing af (Just [])
|
|
|
|
|
|
|
|
addWantDropBy :: String -> Annex ()
|
|
|
|
addWantDropBy name = do
|
|
|
|
u <- Remote.nameToUUID name
|
2023-07-25 20:11:06 +00:00
|
|
|
addPreferredContentLimit "want-drop-by" $ checkWant $ \af ->
|
2022-07-28 17:26:03 +00:00
|
|
|
wantDrop False (Just u) Nothing af (Just [])
|
2020-09-24 21:59:05 +00:00
|
|
|
|
2023-07-25 20:11:06 +00:00
|
|
|
addPreferredContentLimit :: String -> (MatchInfo -> Annex Bool) -> Annex ()
|
|
|
|
addPreferredContentLimit desc a = do
|
2020-09-24 21:59:05 +00:00
|
|
|
nfn <- introspectPreferredRequiredContent matchNeedsFileName Nothing
|
|
|
|
nfc <- introspectPreferredRequiredContent matchNeedsFileContent Nothing
|
|
|
|
nk <- introspectPreferredRequiredContent matchNeedsKey Nothing
|
2020-09-25 14:55:03 +00:00
|
|
|
nl <- introspectPreferredRequiredContent matchNeedsLocationLog Nothing
|
2020-09-24 21:59:05 +00:00
|
|
|
addLimit $ Right $ MatchFiles
|
|
|
|
{ matchAction = const a
|
|
|
|
, matchNeedsFileName = nfn
|
|
|
|
, matchNeedsFileContent = nfc
|
|
|
|
, matchNeedsKey = nk
|
2020-09-25 14:55:03 +00:00
|
|
|
, matchNeedsLocationLog = nl
|
2023-07-25 20:11:06 +00:00
|
|
|
, matchDesc = matchDescSimple desc
|
2020-09-24 21:59:05 +00:00
|
|
|
}
|
2014-01-18 18:51:55 +00:00
|
|
|
|
2017-03-10 17:12:24 +00:00
|
|
|
checkWant :: (AssociatedFile -> Annex Bool) -> MatchInfo -> Annex Bool
|
2019-12-09 17:49:05 +00:00
|
|
|
checkWant a (MatchingFile fi) = a (AssociatedFile (Just $ matchFile fi))
|
2021-03-02 16:47:23 +00:00
|
|
|
checkWant a (MatchingInfo p) = a (AssociatedFile (providedFilePath p))
|
2020-09-28 16:06:10 +00:00
|
|
|
checkWant _ (MatchingUserInfo {}) = return False
|