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.
"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 [] )
- 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
| 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
* 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
)
, 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) $
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))
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 ->
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
* `--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
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]]