new matching options --want-get-by and --want-drop-by
Sponsored-by: Graham Spencer on Patreon
This commit is contained in:
parent
2bb42fa003
commit
be19a68276
11 changed files with 65 additions and 15 deletions
|
@ -22,8 +22,8 @@ wantGet :: Bool -> Maybe Key -> AssociatedFile -> Annex Bool
|
|||
wantGet d key file = isPreferredContent Nothing S.empty key file d
|
||||
|
||||
{- Check if a file is preferred content for a repository. -}
|
||||
wantSend :: Bool -> Maybe Key -> AssociatedFile -> UUID -> Annex Bool
|
||||
wantSend d key file to = isPreferredContent (Just to) S.empty key file d
|
||||
wantGetBy :: Bool -> Maybe Key -> AssociatedFile -> UUID -> Annex Bool
|
||||
wantGetBy d key file to = isPreferredContent (Just to) S.empty key file d
|
||||
|
||||
{- Check if a file is not preferred or required content, and can be
|
||||
- dropped. When a UUID is provided, checks for that repository.
|
||||
|
|
|
@ -171,7 +171,7 @@ expensiveScan urlrenderer rs = batch <~> do
|
|||
"expensive scan found too many copies of object"
|
||||
present key af (SeekInput []) [] callCommandAction
|
||||
ts <- if present
|
||||
then liftAnnex . filterM (wantSend True (Just key) af . Remote.uuid . fst)
|
||||
then liftAnnex . filterM (wantGetBy True (Just key) af . Remote.uuid . fst)
|
||||
=<< use syncDataRemotes (genTransfer Upload False)
|
||||
else ifM (liftAnnex $ wantGet True (Just key) af)
|
||||
( use downloadRemotes (genTransfer Download True) , return [] )
|
||||
|
|
|
@ -88,7 +88,7 @@ queueTransfersMatching matching reason schedule k f direction
|
|||
- already have it. -}
|
||||
| otherwise = do
|
||||
s <- locs
|
||||
filterM (wantSend True (Just k) f . Remote.uuid) $
|
||||
filterM (wantGetBy True (Just k) f . Remote.uuid) $
|
||||
filter (\r -> not (inset s r || Remote.readonly r))
|
||||
(syncDataRemotes st)
|
||||
where
|
||||
|
|
|
@ -212,7 +212,7 @@ shouldTransfer t info
|
|||
| transferDirection t == Upload = case transferRemote info of
|
||||
Nothing -> return False
|
||||
Just r -> notinremote r
|
||||
<&&> wantSend True (Just key) file (Remote.uuid r)
|
||||
<&&> wantGetBy True (Just key) file (Remote.uuid r)
|
||||
| otherwise = return False
|
||||
where
|
||||
key = transferKey t
|
||||
|
|
|
@ -7,6 +7,7 @@ git-annex (10.20220725) UNRELEASED; urgency=medium
|
|||
* Avoid starting an unncessary number of git hash-object processes when
|
||||
concurrency is enabled.
|
||||
* stack.yaml: Updated to lts-19.16
|
||||
* Added new matching options --want-get-by and --want-drop-by.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Mon, 25 Jul 2022 15:35:45 -0400
|
||||
|
||||
|
|
|
@ -288,12 +288,23 @@ keyMatchingOptions' =
|
|||
)
|
||||
, annexFlag (setAnnexState Limit.Wanted.addWantGet)
|
||||
( long "want-get"
|
||||
<> help "match files the repository wants to get"
|
||||
<> help "match files the local repository wants to get"
|
||||
<> hidden
|
||||
)
|
||||
, annexOption (setAnnexState . Limit.Wanted.addWantGetBy) $ strOption
|
||||
( long "want-get-by" <> metavar paramRemote
|
||||
<> help "match files the specified repository wants to get"
|
||||
<> hidden
|
||||
<> completeRemotes
|
||||
)
|
||||
, annexFlag (setAnnexState Limit.Wanted.addWantDrop)
|
||||
( long "want-drop"
|
||||
<> help "match files the repository wants to drop"
|
||||
<> help "match files the local repository wants to drop"
|
||||
<> hidden
|
||||
)
|
||||
, annexOption (setAnnexState . Limit.Wanted.addWantDropBy) $ strOption
|
||||
( long "want-drop-by" <> metavar paramRemote
|
||||
<> help "match files the specified repository wants to drop"
|
||||
<> hidden
|
||||
)
|
||||
, annexOption (setAnnexState . Limit.addAccessedWithin) $
|
||||
|
|
|
@ -82,5 +82,5 @@ start o si file key = stopUnless shouldCopy $
|
|||
Right (FromRemote _) -> checkwantget
|
||||
Left ToHere -> checkwantget
|
||||
|
||||
checkwantsend = wantSend False (Just key) (AssociatedFile (Just file))
|
||||
checkwantsend = wantGetBy False (Just key) (AssociatedFile (Just file))
|
||||
checkwantget = wantGet False (Just key) (AssociatedFile (Just file))
|
||||
|
|
|
@ -855,7 +855,7 @@ syncFile ebloom rs af k = do
|
|||
wantput r
|
||||
| Remote.readonly r || remoteAnnexReadOnly (Remote.gitconfig r) = return False
|
||||
| isThirdPartyPopulated r = return False
|
||||
| otherwise = wantSend True (Just k) af (Remote.uuid r)
|
||||
| otherwise = wantGetBy True (Just k) af (Remote.uuid r)
|
||||
handleput lack inhere
|
||||
| inhere = catMaybes <$>
|
||||
( forM lack $ \r ->
|
||||
|
|
|
@ -12,14 +12,27 @@ import Annex.Wanted
|
|||
import Limit
|
||||
import Types.FileMatcher
|
||||
import Logs.PreferredContent
|
||||
import qualified Remote
|
||||
|
||||
addWantGet :: Annex ()
|
||||
addWantGet = addPreferredContentLimit $
|
||||
checkWant $ wantGet False Nothing
|
||||
|
||||
addWantGetBy :: String -> Annex ()
|
||||
addWantGetBy name = do
|
||||
u <- Remote.nameToUUID name
|
||||
addPreferredContentLimit $ checkWant $ \af ->
|
||||
wantGetBy False Nothing af u
|
||||
|
||||
addWantDrop :: Annex ()
|
||||
addWantDrop = addPreferredContentLimit $
|
||||
checkWant $ \af -> wantDrop False Nothing Nothing af (Just [])
|
||||
addWantDrop = addPreferredContentLimit $ checkWant $ \af ->
|
||||
wantDrop False Nothing Nothing af (Just [])
|
||||
|
||||
addWantDropBy :: String -> Annex ()
|
||||
addWantDropBy name = do
|
||||
u <- Remote.nameToUUID name
|
||||
addPreferredContentLimit $ checkWant $ \af ->
|
||||
wantDrop False (Just u) Nothing af (Just [])
|
||||
|
||||
addPreferredContentLimit :: (MatchInfo -> Annex Bool) -> Annex ()
|
||||
addPreferredContentLimit a = do
|
||||
|
|
|
@ -153,21 +153,43 @@ in either of two repositories.
|
|||
|
||||
* `--want-get`
|
||||
|
||||
Matches only when the preferred content settings for the repository
|
||||
Matches only when the preferred content settings for the local repository
|
||||
make it want to get content. Note that this will match even when
|
||||
the content is already present, unless limited with e.g., `--not --in .`
|
||||
the content is already present, unless limited with e.g., `--not --in=here`
|
||||
|
||||
* `--want-drop`
|
||||
|
||||
Matches only when the preferred content settings for the repository
|
||||
Matches only when the preferred content settings for the local repository
|
||||
make it want to drop content. Note that this will match even when
|
||||
the content is not present, unless limited with e.g., `--in .`
|
||||
the content is not present, unless limited with e.g., `--not --in=here`
|
||||
|
||||
Things that this matches will not necessarily be dropped by
|
||||
`git-annex drop --auto`. This does not check that there are enough copies
|
||||
to drop. Also the same content may be used by a file that is not wanted
|
||||
to be dropped.
|
||||
|
||||
* `--want-get-by=repository`
|
||||
|
||||
Matches only when the preferred content settings for the specified
|
||||
repository make it want to get content. Note that this will match even when
|
||||
the content is already present in that repository, unless limited with e.g.,
|
||||
`--not --in=repository`
|
||||
|
||||
The repository should be specified using the name of a configured remote,
|
||||
or the UUID or description of a repository. `--want-get-by=here`
|
||||
is the same as `--want-get`.
|
||||
|
||||
* `--want-drop-by=repository`
|
||||
|
||||
Matches only when the preferred content settings for the specificed
|
||||
repository make it want to drop content. Note that this will match
|
||||
even when the content is not present, unless limited with e.g.,
|
||||
`--not --in=repository`
|
||||
|
||||
The repository should be specified using the name of a configured remote,
|
||||
or the UUID or description of a repository. `--want-drop-by=here`
|
||||
is the same as `--want-drop`.
|
||||
|
||||
* `--accessedwithin=interval`
|
||||
|
||||
Matches when the content was accessed recently, within the specified time
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
Could a --dry-run option be added to the git annex commands? Or, at least, to the most common ones like `git annex add`.
|
||||
|
||||
Given that there is no undo command, it would be nice to have the ability to simulate what git annex will do.
|
||||
|
||||
> [[wontfix|done]], see comments. Instead, options like --want-get and
|
||||
> --want-drop can be used to simulate things. --[[Joey]]
|
||||
|
|
Loading…
Reference in a new issue