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" $
|
2024-08-23 20:35:12 +00:00
|
|
|
checkWant $ wantGet NoLiveUpdate 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 ->
|
2024-08-23 20:35:12 +00:00
|
|
|
wantGetBy NoLiveUpdate False Nothing af u
|
2022-07-28 17:26:03 +00:00
|
|
|
|
2013-10-28 18:50:17 +00:00
|
|
|
addWantDrop :: Annex ()
|
2023-07-25 20:11:06 +00:00
|
|
|
addWantDrop = addPreferredContentLimit "want-drop" $ checkWant $ \af ->
|
2024-08-23 20:35:12 +00:00
|
|
|
wantDrop NoLiveUpdate False Nothing Nothing af (Just [])
|
2022-07-28 17:26:03 +00:00
|
|
|
|
|
|
|
addWantDropBy :: String -> Annex ()
|
|
|
|
addWantDropBy name = do
|
|
|
|
u <- Remote.nameToUUID name
|
2023-07-25 20:11:06 +00:00
|
|
|
addPreferredContentLimit "want-drop-by" $ checkWant $ \af ->
|
2024-08-23 20:35:12 +00:00
|
|
|
wantDrop NoLiveUpdate 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
|
2024-08-28 14:52:34 +00:00
|
|
|
lsz <- introspectPreferredRequiredContent matchNeedsLiveRepoSize Nothing
|
2020-09-24 21:59:05 +00:00
|
|
|
addLimit $ Right $ MatchFiles
|
2024-08-23 20:35:12 +00:00
|
|
|
{ matchAction = const $ const a
|
2020-09-24 21:59:05 +00:00
|
|
|
, matchNeedsFileName = nfn
|
|
|
|
, matchNeedsFileContent = nfc
|
|
|
|
, matchNeedsKey = nk
|
2020-09-25 14:55:03 +00:00
|
|
|
, matchNeedsLocationLog = nl
|
2024-08-28 14:52:34 +00:00
|
|
|
, matchNeedsLiveRepoSize = lsz
|
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
|