add remote.<name>.annex-checkuuid
Added remote.<name>.annex-checkuuid config, which can be set to false to disable the default checking of the uuid of remotes that point to directories. This can be useful to avoid unncessary drive spin-ups and automounting. Note that the UUID check is still done before writing to the repository, to avoid writing to the wrong repository if it got relocated. Check is also done before checkPresent to avoid getting confused about what is in which repo. This is effectively the same as the use of git-annex-shell with a uuid to check that the remote repository is the expected one. Did not bother with the check for retrieveKeyFile because it doesn't matter if the wrong repo is used then. This commit was sponsored by Trenton Cronholm on Patreon.
This commit is contained in:
parent
c83c2acf9c
commit
a28c541e23
6 changed files with 97 additions and 26 deletions
|
@ -16,6 +16,10 @@ git-annex (6.20171215) UNRELEASED; urgency=medium
|
||||||
* Improve startup time for commands that do not operate on remotes,
|
* Improve startup time for commands that do not operate on remotes,
|
||||||
and for tab completion, by not unnessessarily statting paths to
|
and for tab completion, by not unnessessarily statting paths to
|
||||||
remotes, which used to cause eg, spin-up of removable drives.
|
remotes, which used to cause eg, spin-up of removable drives.
|
||||||
|
* Added remote.<name>.annex-checkuuid config, which can be set to false
|
||||||
|
to disable the default checking of the uuid of remotes that point to
|
||||||
|
directories. This can be useful to avoid unncessary drive spin-ups and
|
||||||
|
automounting.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Wed, 20 Dec 2017 12:11:46 -0400
|
-- Joey Hess <id@joeyh.name> Wed, 20 Dec 2017 12:11:46 -0400
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{- Standard git remotes.
|
{- Standard git remotes.
|
||||||
-
|
-
|
||||||
- Copyright 2011-2017 Joey Hess <id@joeyh.name>
|
- Copyright 2011-2018 Joey Hess <id@joeyh.name>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -123,7 +123,8 @@ gitSetup (Enable _) (Just u) _ c _ = do
|
||||||
gitSetup (Enable _) Nothing _ _ _ = error "unable to enable git remote with no specified uuid"
|
gitSetup (Enable _) Nothing _ _ _ = error "unable to enable git remote with no specified uuid"
|
||||||
|
|
||||||
{- It's assumed to be cheap to read the config of non-URL remotes, so this is
|
{- It's assumed to be cheap to read the config of non-URL remotes, so this is
|
||||||
- done each time git-annex is run in a way that uses remotes.
|
- done each time git-annex is run in a way that uses remotes, unless
|
||||||
|
- annex-checkuuid is false.
|
||||||
-
|
-
|
||||||
- Conversely, the config of an URL remote is only read when there is no
|
- Conversely, the config of an URL remote is only read when there is no
|
||||||
- cached UUID value. -}
|
- cached UUID value. -}
|
||||||
|
@ -134,7 +135,9 @@ configRead autoinit r = do
|
||||||
annexignore <- liftIO $ getDynamicConfig (remoteAnnexIgnore gc)
|
annexignore <- liftIO $ getDynamicConfig (remoteAnnexIgnore gc)
|
||||||
case (repoCheap r, annexignore, u) of
|
case (repoCheap r, annexignore, u) of
|
||||||
(_, True, _) -> return r
|
(_, True, _) -> return r
|
||||||
(True, _, _) -> tryGitConfigRead autoinit r
|
(True, _, _)
|
||||||
|
| remoteAnnexCheckUUID gc -> tryGitConfigRead autoinit r
|
||||||
|
| otherwise -> return r
|
||||||
(False, _, NoUUID) -> tryGitConfigRead autoinit r
|
(False, _, NoUUID) -> tryGitConfigRead autoinit r
|
||||||
_ -> return r
|
_ -> return r
|
||||||
|
|
||||||
|
@ -142,22 +145,24 @@ gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> Annex (Maybe Remot
|
||||||
gen r u c gc
|
gen r u c gc
|
||||||
| Git.GCrypt.isEncrypted r = Remote.GCrypt.chainGen r u c gc
|
| Git.GCrypt.isEncrypted r = Remote.GCrypt.chainGen r u c gc
|
||||||
| otherwise = case repoP2PAddress r of
|
| otherwise = case repoP2PAddress r of
|
||||||
Nothing -> go <$> remoteCost gc defcst
|
Nothing -> do
|
||||||
|
duc <- mkDeferredUUIDCheck r u gc
|
||||||
|
go duc <$> remoteCost gc defcst
|
||||||
Just addr -> Remote.P2P.chainGen addr r u c gc
|
Just addr -> Remote.P2P.chainGen addr r u c gc
|
||||||
where
|
where
|
||||||
defcst = if repoCheap r then cheapRemoteCost else expensiveRemoteCost
|
defcst = if repoCheap r then cheapRemoteCost else expensiveRemoteCost
|
||||||
go cst = Just new
|
go duc cst = Just new
|
||||||
where
|
where
|
||||||
new = Remote
|
new = Remote
|
||||||
{ uuid = u
|
{ uuid = u
|
||||||
, cost = cst
|
, cost = cst
|
||||||
, name = Git.repoDescribe r
|
, name = Git.repoDescribe r
|
||||||
, storeKey = copyToRemote new
|
, storeKey = copyToRemote new duc
|
||||||
, retrieveKeyFile = copyFromRemote new
|
, retrieveKeyFile = copyFromRemote new
|
||||||
, retrieveKeyFileCheap = copyFromRemoteCheap new
|
, retrieveKeyFileCheap = copyFromRemoteCheap new
|
||||||
, removeKey = dropKey new
|
, removeKey = dropKey new duc
|
||||||
, lockContent = Just (lockKey new)
|
, lockContent = Just (lockKey new duc)
|
||||||
, checkPresent = inAnnex new
|
, checkPresent = inAnnex new duc
|
||||||
, checkPresentCheap = repoCheap r
|
, checkPresentCheap = repoCheap r
|
||||||
, exportActions = exportUnsupported
|
, exportActions = exportUnsupported
|
||||||
, whereisKey = Nothing
|
, whereisKey = Nothing
|
||||||
|
@ -322,8 +327,8 @@ tryGitConfigRead autoinit r
|
||||||
else []
|
else []
|
||||||
|
|
||||||
{- Checks if a given remote has the content for a key in its annex. -}
|
{- Checks if a given remote has the content for a key in its annex. -}
|
||||||
inAnnex :: Remote -> Key -> Annex Bool
|
inAnnex :: Remote -> DeferredUUIDCheck -> Key -> Annex Bool
|
||||||
inAnnex rmt key
|
inAnnex rmt duc key
|
||||||
| Git.repoIsHttp r = checkhttp
|
| Git.repoIsHttp r = checkhttp
|
||||||
| Git.repoIsUrl r = checkremote
|
| Git.repoIsUrl r = checkremote
|
||||||
| otherwise = checklocal
|
| otherwise = checklocal
|
||||||
|
@ -336,9 +341,12 @@ inAnnex rmt key
|
||||||
, giveup "not found"
|
, giveup "not found"
|
||||||
)
|
)
|
||||||
checkremote = Ssh.inAnnex r key
|
checkremote = Ssh.inAnnex r key
|
||||||
checklocal = guardUsable r (cantCheck r) $
|
checklocal = ifM duc
|
||||||
|
( guardUsable r (cantCheck r) $
|
||||||
maybe (cantCheck r) return
|
maybe (cantCheck r) return
|
||||||
=<< onLocalFast rmt (Annex.Content.inAnnexSafe key)
|
=<< onLocalFast rmt (Annex.Content.inAnnexSafe key)
|
||||||
|
, cantCheck r
|
||||||
|
)
|
||||||
|
|
||||||
keyUrls :: Remote -> Key -> [String]
|
keyUrls :: Remote -> Key -> [String]
|
||||||
keyUrls r key = map tourl locs'
|
keyUrls r key = map tourl locs'
|
||||||
|
@ -357,10 +365,10 @@ keyUrls r key = map tourl locs'
|
||||||
remoteconfig = gitconfig r
|
remoteconfig = gitconfig r
|
||||||
cfg = remoteGitConfig remoteconfig
|
cfg = remoteGitConfig remoteconfig
|
||||||
|
|
||||||
dropKey :: Remote -> Key -> Annex Bool
|
dropKey :: Remote -> DeferredUUIDCheck -> Key -> Annex Bool
|
||||||
dropKey r key
|
dropKey r duc key
|
||||||
| not $ Git.repoIsUrl (repo r) =
|
| not $ Git.repoIsUrl (repo r) = ifM duc
|
||||||
guardUsable (repo r) (return False) $
|
( guardUsable (repo r) (return False) $
|
||||||
commitOnCleanup r $ onLocalFast r $ do
|
commitOnCleanup r $ onLocalFast r $ do
|
||||||
ensureInitialized
|
ensureInitialized
|
||||||
whenM (Annex.Content.inAnnex key) $ do
|
whenM (Annex.Content.inAnnex key) $ do
|
||||||
|
@ -369,13 +377,15 @@ dropKey r key
|
||||||
logStatus key InfoMissing
|
logStatus key InfoMissing
|
||||||
Annex.Content.saveState True
|
Annex.Content.saveState True
|
||||||
return True
|
return True
|
||||||
|
, return False
|
||||||
|
)
|
||||||
| Git.repoIsHttp (repo r) = giveup "dropping from http remote not supported"
|
| Git.repoIsHttp (repo r) = giveup "dropping from http remote not supported"
|
||||||
| otherwise = commitOnCleanup r $ Ssh.dropKey (repo r) key
|
| otherwise = commitOnCleanup r $ Ssh.dropKey (repo r) key
|
||||||
|
|
||||||
lockKey :: Remote -> Key -> (VerifiedCopy -> Annex r) -> Annex r
|
lockKey :: Remote -> DeferredUUIDCheck -> Key -> (VerifiedCopy -> Annex r) -> Annex r
|
||||||
lockKey r key callback
|
lockKey r duc key callback
|
||||||
| not $ Git.repoIsUrl (repo r) =
|
| not $ Git.repoIsUrl (repo r) = ifM duc
|
||||||
guardUsable (repo r) failedlock $ do
|
( guardUsable (repo r) failedlock $ do
|
||||||
inorigrepo <- Annex.makeRunner
|
inorigrepo <- Annex.makeRunner
|
||||||
-- Lock content from perspective of remote,
|
-- Lock content from perspective of remote,
|
||||||
-- and then run the callback in the original
|
-- and then run the callback in the original
|
||||||
|
@ -386,6 +396,8 @@ lockKey r key callback
|
||||||
( liftIO $ inorigrepo $ callback vc
|
( liftIO $ inorigrepo $ callback vc
|
||||||
, failedlock
|
, failedlock
|
||||||
)
|
)
|
||||||
|
, failedlock
|
||||||
|
)
|
||||||
| Git.repoIsSsh (repo r) = do
|
| Git.repoIsSsh (repo r) = do
|
||||||
showLocking r
|
showLocking r
|
||||||
Just (cmd, params) <- Ssh.git_annex_shell ConsumeStdin
|
Just (cmd, params) <- Ssh.git_annex_shell ConsumeStdin
|
||||||
|
@ -544,11 +556,13 @@ copyFromRemoteCheap _ _ _ _ = return False
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{- Tries to copy a key's content to a remote's annex. -}
|
{- Tries to copy a key's content to a remote's annex. -}
|
||||||
copyToRemote :: Remote -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool
|
copyToRemote :: Remote -> DeferredUUIDCheck -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool
|
||||||
copyToRemote r key file meterupdate
|
copyToRemote r duc key file meterupdate
|
||||||
| not $ Git.repoIsUrl (repo r) =
|
| not $ Git.repoIsUrl (repo r) = ifM duc
|
||||||
guardUsable (repo r) (return False) $ commitOnCleanup r $
|
( guardUsable (repo r) (return False) $ commitOnCleanup r $
|
||||||
copylocal =<< Annex.Content.prepSendAnnex key
|
copylocal =<< Annex.Content.prepSendAnnex key
|
||||||
|
, return False
|
||||||
|
)
|
||||||
| Git.repoIsSsh (repo r) = commitOnCleanup r $
|
| Git.repoIsSsh (repo r) = commitOnCleanup r $
|
||||||
Annex.Content.sendAnnex key noop $ \object ->
|
Annex.Content.sendAnnex key noop $ \object ->
|
||||||
withmeter object $ \p -> do
|
withmeter object $ \p -> do
|
||||||
|
@ -717,3 +731,26 @@ mkCopier remotewanthardlink rsyncparams = do
|
||||||
)
|
)
|
||||||
, return copier
|
, return copier
|
||||||
)
|
)
|
||||||
|
|
||||||
|
{- Normally the UUID is checked at startup, but annex-checkuuid config
|
||||||
|
- can prevent that. To avoid getting confused, a deferred
|
||||||
|
- check is done just before the repository is used. This returns False
|
||||||
|
- when the repository UUID is not as expected. -}
|
||||||
|
type DeferredUUIDCheck = Annex Bool
|
||||||
|
|
||||||
|
mkDeferredUUIDCheck :: Git.Repo -> UUID -> RemoteGitConfig -> Annex DeferredUUIDCheck
|
||||||
|
mkDeferredUUIDCheck r u gc
|
||||||
|
| remoteAnnexCheckUUID gc = return (return True)
|
||||||
|
| otherwise = do
|
||||||
|
v <- liftIO newEmptyMVar
|
||||||
|
return $ ifM (liftIO $ isEmptyMVar v)
|
||||||
|
( do
|
||||||
|
r' <- tryGitConfigRead False r
|
||||||
|
u' <- getRepoUUID r'
|
||||||
|
let ok = u' == u
|
||||||
|
void $ liftIO $ tryPutMVar v ok
|
||||||
|
unless ok $
|
||||||
|
warning $ Git.repoDescribe r ++ " is not the expected repository. The remote's annex-checkuuid configuration prevented noticing the change until now."
|
||||||
|
return ok
|
||||||
|
, liftIO $ readMVar v
|
||||||
|
)
|
||||||
|
|
|
@ -199,6 +199,7 @@ data RemoteGitConfig = RemoteGitConfig
|
||||||
, remoteAnnexPush :: Bool
|
, remoteAnnexPush :: Bool
|
||||||
, remoteAnnexReadOnly :: Bool
|
, remoteAnnexReadOnly :: Bool
|
||||||
, remoteAnnexVerify :: Bool
|
, remoteAnnexVerify :: Bool
|
||||||
|
, remoteAnnexCheckUUID :: Bool
|
||||||
, remoteAnnexExportTracking :: Maybe Git.Ref
|
, remoteAnnexExportTracking :: Maybe Git.Ref
|
||||||
, remoteAnnexTrustLevel :: Maybe String
|
, remoteAnnexTrustLevel :: Maybe String
|
||||||
, remoteAnnexStartCommand :: Maybe String
|
, remoteAnnexStartCommand :: Maybe String
|
||||||
|
@ -247,6 +248,7 @@ extractRemoteGitConfig r remotename = do
|
||||||
, remoteAnnexPull = getbool "pull" True
|
, remoteAnnexPull = getbool "pull" True
|
||||||
, remoteAnnexPush = getbool "push" True
|
, remoteAnnexPush = getbool "push" True
|
||||||
, remoteAnnexReadOnly = getbool "readonly" False
|
, remoteAnnexReadOnly = getbool "readonly" False
|
||||||
|
, remoteAnnexCheckUUID = getbool "checkuuid" True
|
||||||
, remoteAnnexVerify = getbool "verify" True
|
, remoteAnnexVerify = getbool "verify" True
|
||||||
, remoteAnnexExportTracking = Git.Ref
|
, remoteAnnexExportTracking = Git.Ref
|
||||||
<$> notempty (getmaybe "export-tracking")
|
<$> notempty (getmaybe "export-tracking")
|
||||||
|
|
|
@ -42,3 +42,6 @@ Use any git-annex command and wait for at least `x-systemd.device-timeout`:
|
||||||
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
|
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
|
||||||
|
|
||||||
I’m very happy with git-annex (thanks) and use it frequently enough to notice this behavior.
|
I’m very happy with git-annex (thanks) and use it frequently enough to notice this behavior.
|
||||||
|
|
||||||
|
> [[fixed|done]] via the `remote.<name>.annex-checkuuid` config setting
|
||||||
|
> that can disable this behavior. --[[Joey]]
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
[[!comment format=mdwn
|
||||||
|
username="joey"
|
||||||
|
subject="""comment 4"""
|
||||||
|
date="2018-01-10T17:37:42Z"
|
||||||
|
content="""
|
||||||
|
Added remote.<name>.annex-checkuuid config, which can be set to false
|
||||||
|
to disable the default checking of the uuid. It will still check before
|
||||||
|
making any modification of the remote repository.
|
||||||
|
|
||||||
|
There may still be situations where using this kind of automount is suboptimal
|
||||||
|
with git-annex, as outlined in comment 3, but I think this is as far as it makes
|
||||||
|
sense to change git-annex to deal with them.
|
||||||
|
"""]]
|
|
@ -1234,6 +1234,18 @@ Here are all the supported configuration settings.
|
||||||
|
|
||||||
git-annex caches UUIDs of remote repositories here.
|
git-annex caches UUIDs of remote repositories here.
|
||||||
|
|
||||||
|
- `remote.<name>.annex-checkuuid`
|
||||||
|
|
||||||
|
This only affects remotes that have their url pointing to a directory on
|
||||||
|
the same system. git-annex normally checks the uuid of such
|
||||||
|
remotes each time it's run, which lets it transparently deal with
|
||||||
|
different drives being mounted to the location at different times.
|
||||||
|
|
||||||
|
Setting annex-checkuuid to false will prevent it from checking the uuid
|
||||||
|
at startup (although the uuid is still verified before making any
|
||||||
|
changes to the remote repository). This may be useful to set to prevent
|
||||||
|
unncessary spin-up or automounting of a drive.
|
||||||
|
|
||||||
* `remote.<name>.annex-trustlevel`
|
* `remote.<name>.annex-trustlevel`
|
||||||
|
|
||||||
Configures a local trust level for the remote. This overrides the value
|
Configures a local trust level for the remote. This overrides the value
|
||||||
|
|
Loading…
Reference in a new issue