summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG4
-rw-r--r--Remote/Git.hs89
-rw-r--r--Types/GitConfig.hs2
-rw-r--r--doc/bugs/Missing_automounts_block_every_command.mdwn3
-rw-r--r--doc/bugs/Missing_automounts_block_every_command/comment_4_c3cfb1c27806c45dfa6ebf275c175d3e._comment13
-rw-r--r--doc/git-annex.mdwn12
6 files changed, 97 insertions, 26 deletions
diff --git a/CHANGELOG b/CHANGELOG
index fe5dba4cd..32fbcabad 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -16,6 +16,10 @@ git-annex (6.20171215) UNRELEASED; urgency=medium
* Improve startup time for commands that do not operate on remotes,
and for tab completion, by not unnessessarily statting paths to
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
diff --git a/Remote/Git.hs b/Remote/Git.hs
index 8df14937e..2cebcce4a 100644
--- a/Remote/Git.hs
+++ b/Remote/Git.hs
@@ -1,6 +1,6 @@
{- 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.
-}
@@ -123,7 +123,8 @@ gitSetup (Enable _) (Just u) _ c _ = do
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
- - 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
- cached UUID value. -}
@@ -134,7 +135,9 @@ configRead autoinit r = do
annexignore <- liftIO $ getDynamicConfig (remoteAnnexIgnore gc)
case (repoCheap r, annexignore, u) of
(_, True, _) -> return r
- (True, _, _) -> tryGitConfigRead autoinit r
+ (True, _, _)
+ | remoteAnnexCheckUUID gc -> tryGitConfigRead autoinit r
+ | otherwise -> return r
(False, _, NoUUID) -> tryGitConfigRead autoinit r
_ -> return r
@@ -142,22 +145,24 @@ gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> Annex (Maybe Remot
gen r u c gc
| Git.GCrypt.isEncrypted r = Remote.GCrypt.chainGen r u c gc
| 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
where
defcst = if repoCheap r then cheapRemoteCost else expensiveRemoteCost
- go cst = Just new
+ go duc cst = Just new
where
new = Remote
{ uuid = u
, cost = cst
, name = Git.repoDescribe r
- , storeKey = copyToRemote new
+ , storeKey = copyToRemote new duc
, retrieveKeyFile = copyFromRemote new
, retrieveKeyFileCheap = copyFromRemoteCheap new
- , removeKey = dropKey new
- , lockContent = Just (lockKey new)
- , checkPresent = inAnnex new
+ , removeKey = dropKey new duc
+ , lockContent = Just (lockKey new duc)
+ , checkPresent = inAnnex new duc
, checkPresentCheap = repoCheap r
, exportActions = exportUnsupported
, whereisKey = Nothing
@@ -322,8 +327,8 @@ tryGitConfigRead autoinit r
else []
{- Checks if a given remote has the content for a key in its annex. -}
-inAnnex :: Remote -> Key -> Annex Bool
-inAnnex rmt key
+inAnnex :: Remote -> DeferredUUIDCheck -> Key -> Annex Bool
+inAnnex rmt duc key
| Git.repoIsHttp r = checkhttp
| Git.repoIsUrl r = checkremote
| otherwise = checklocal
@@ -336,9 +341,12 @@ inAnnex rmt key
, giveup "not found"
)
checkremote = Ssh.inAnnex r key
- checklocal = guardUsable r (cantCheck r) $
- maybe (cantCheck r) return
- =<< onLocalFast rmt (Annex.Content.inAnnexSafe key)
+ checklocal = ifM duc
+ ( guardUsable r (cantCheck r) $
+ maybe (cantCheck r) return
+ =<< onLocalFast rmt (Annex.Content.inAnnexSafe key)
+ , cantCheck r
+ )
keyUrls :: Remote -> Key -> [String]
keyUrls r key = map tourl locs'
@@ -357,10 +365,10 @@ keyUrls r key = map tourl locs'
remoteconfig = gitconfig r
cfg = remoteGitConfig remoteconfig
-dropKey :: Remote -> Key -> Annex Bool
-dropKey r key
- | not $ Git.repoIsUrl (repo r) =
- guardUsable (repo r) (return False) $
+dropKey :: Remote -> DeferredUUIDCheck -> Key -> Annex Bool
+dropKey r duc key
+ | not $ Git.repoIsUrl (repo r) = ifM duc
+ ( guardUsable (repo r) (return False) $
commitOnCleanup r $ onLocalFast r $ do
ensureInitialized
whenM (Annex.Content.inAnnex key) $ do
@@ -369,13 +377,15 @@ dropKey r key
logStatus key InfoMissing
Annex.Content.saveState True
return True
+ , return False
+ )
| Git.repoIsHttp (repo r) = giveup "dropping from http remote not supported"
| otherwise = commitOnCleanup r $ Ssh.dropKey (repo r) key
-lockKey :: Remote -> Key -> (VerifiedCopy -> Annex r) -> Annex r
-lockKey r key callback
- | not $ Git.repoIsUrl (repo r) =
- guardUsable (repo r) failedlock $ do
+lockKey :: Remote -> DeferredUUIDCheck -> Key -> (VerifiedCopy -> Annex r) -> Annex r
+lockKey r duc key callback
+ | not $ Git.repoIsUrl (repo r) = ifM duc
+ ( guardUsable (repo r) failedlock $ do
inorigrepo <- Annex.makeRunner
-- Lock content from perspective of remote,
-- and then run the callback in the original
@@ -386,6 +396,8 @@ lockKey r key callback
( liftIO $ inorigrepo $ callback vc
, failedlock
)
+ , failedlock
+ )
| Git.repoIsSsh (repo r) = do
showLocking r
Just (cmd, params) <- Ssh.git_annex_shell ConsumeStdin
@@ -544,11 +556,13 @@ copyFromRemoteCheap _ _ _ _ = return False
#endif
{- Tries to copy a key's content to a remote's annex. -}
-copyToRemote :: Remote -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool
-copyToRemote r key file meterupdate
- | not $ Git.repoIsUrl (repo r) =
- guardUsable (repo r) (return False) $ commitOnCleanup r $
+copyToRemote :: Remote -> DeferredUUIDCheck -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool
+copyToRemote r duc key file meterupdate
+ | not $ Git.repoIsUrl (repo r) = ifM duc
+ ( guardUsable (repo r) (return False) $ commitOnCleanup r $
copylocal =<< Annex.Content.prepSendAnnex key
+ , return False
+ )
| Git.repoIsSsh (repo r) = commitOnCleanup r $
Annex.Content.sendAnnex key noop $ \object ->
withmeter object $ \p -> do
@@ -717,3 +731,26 @@ mkCopier remotewanthardlink rsyncparams = do
)
, 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
+ )
diff --git a/Types/GitConfig.hs b/Types/GitConfig.hs
index 9a48ad173..ad22dadb8 100644
--- a/Types/GitConfig.hs
+++ b/Types/GitConfig.hs
@@ -199,6 +199,7 @@ data RemoteGitConfig = RemoteGitConfig
, remoteAnnexPush :: Bool
, remoteAnnexReadOnly :: Bool
, remoteAnnexVerify :: Bool
+ , remoteAnnexCheckUUID :: Bool
, remoteAnnexExportTracking :: Maybe Git.Ref
, remoteAnnexTrustLevel :: Maybe String
, remoteAnnexStartCommand :: Maybe String
@@ -247,6 +248,7 @@ extractRemoteGitConfig r remotename = do
, remoteAnnexPull = getbool "pull" True
, remoteAnnexPush = getbool "push" True
, remoteAnnexReadOnly = getbool "readonly" False
+ , remoteAnnexCheckUUID = getbool "checkuuid" True
, remoteAnnexVerify = getbool "verify" True
, remoteAnnexExportTracking = Git.Ref
<$> notempty (getmaybe "export-tracking")
diff --git a/doc/bugs/Missing_automounts_block_every_command.mdwn b/doc/bugs/Missing_automounts_block_every_command.mdwn
index 12a3463e8..53af6f15a 100644
--- a/doc/bugs/Missing_automounts_block_every_command.mdwn
+++ b/doc/bugs/Missing_automounts_block_every_command.mdwn
@@ -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)
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]]
diff --git a/doc/bugs/Missing_automounts_block_every_command/comment_4_c3cfb1c27806c45dfa6ebf275c175d3e._comment b/doc/bugs/Missing_automounts_block_every_command/comment_4_c3cfb1c27806c45dfa6ebf275c175d3e._comment
new file mode 100644
index 000000000..31f97beeb
--- /dev/null
+++ b/doc/bugs/Missing_automounts_block_every_command/comment_4_c3cfb1c27806c45dfa6ebf275c175d3e._comment
@@ -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.
+"""]]
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index d4502cdfa..f427d9409 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -1234,6 +1234,18 @@ Here are all the supported configuration settings.
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`
Configures a local trust level for the remote. This overrides the value