consolidate calls to ensureInitialized
tryGitConfigRead may run ensureInitialized first, but when checkuuid = false, that is skipped. So, make sure it's run before all onLocal actions. ensureInitialized is inexpensive, so the extra call by tryGitConfigRead is not a big deal. But since it was easy to do, I made it only be run once by all calls to onLocal. A few calls to onLocal didn't call ensureInitialized before. Notably, the checkPresent action didn't, and does now. That means that there's a guarantee that any necessary repo upgrades will be run before the checkPresent action runs in the repo. Which is important especially for the direct mode conversion, because without that upgrade, the checkPresent action would need to support direct mode still. Now I can remove the last bits of direct mode support in Annex.Content without worrying that it will break accessing remotes that have not been upgraded. This does necessarily mean that checkPresent needs to write to the disk when performing such a repo upgrade. The other remote actions already did, so retrieval from a readonly remote that needed to be upgraded would fail. Having checkPresent also fail doesn't seem like a large reversion, especially since it already failed in the default case when checkuuid = true.
This commit is contained in:
parent
6b56c3ae11
commit
bb18bbd426
1 changed files with 11 additions and 10 deletions
|
@ -324,7 +324,7 @@ tryGitConfigRead autoinit r
|
|||
readlocalannexconfig = do
|
||||
let check = do
|
||||
Annex.BranchState.disableUpdate
|
||||
void $ tryNonAsync $ ensureInitialized
|
||||
void $ tryNonAsync ensureInitialized
|
||||
Annex.getState Annex.repo
|
||||
s <- Annex.new r
|
||||
Annex.eval s $ check `finally` stopCoProcesses
|
||||
|
@ -391,7 +391,6 @@ dropKey' repo r (State connpool duc _ _) key
|
|||
| not $ Git.repoIsUrl repo = ifM duc
|
||||
( guardUsable repo (return False) $
|
||||
commitOnCleanup repo r $ onLocalFast repo r $ do
|
||||
ensureInitialized
|
||||
whenM (Annex.Content.inAnnex key) $ do
|
||||
Annex.Content.lockContentForRemoval key $ \lock -> do
|
||||
Annex.Content.removeAnnex lock
|
||||
|
@ -489,7 +488,6 @@ copyFromRemote'' repo forcersync r st@(State connpool _ _ _) key file dest meter
|
|||
hardlink <- wantHardLink
|
||||
-- run copy from perspective of remote
|
||||
onLocalFast repo r $ do
|
||||
ensureInitialized
|
||||
v <- Annex.Content.prepSendAnnex key
|
||||
case v of
|
||||
Nothing -> return (False, UnVerified)
|
||||
|
@ -631,7 +629,6 @@ copyToRemote' repo r st@(State connpool duc _ _) key file meterupdate
|
|||
onLocalFast repo r $ ifM (Annex.Content.inAnnex key)
|
||||
( return True
|
||||
, do
|
||||
ensureInitialized
|
||||
copier <- mkCopier hardlink st params
|
||||
let verify = Annex.Content.RemoteVerify r
|
||||
let rsp = RetrievalAllKeysSecure
|
||||
|
@ -681,21 +678,25 @@ repairRemote r a = return $ do
|
|||
- The AnnexState is cached for speed and to avoid resource leaks.
|
||||
- However, coprocesses are stopped after each call to avoid git
|
||||
- processes hanging around on removable media.
|
||||
-
|
||||
- The remote will be automatically initialized/upgraded first,
|
||||
- when possible.
|
||||
-}
|
||||
onLocal :: Git.Repo -> Remote -> Annex a -> Annex a
|
||||
onLocal repo r a = do
|
||||
m <- Annex.getState Annex.remoteannexstate
|
||||
go =<< maybe
|
||||
(liftIO $ Annex.new repo)
|
||||
return
|
||||
(M.lookup (uuid r) m)
|
||||
case M.lookup (uuid r) m of
|
||||
Nothing -> do
|
||||
st <- liftIO $ Annex.new repo
|
||||
go (st, ensureInitialized >> a)
|
||||
Just st -> go (st, a)
|
||||
where
|
||||
cache st = Annex.changeState $ \s -> s
|
||||
{ Annex.remoteannexstate = M.insert (uuid r) st (Annex.remoteannexstate s) }
|
||||
go st = do
|
||||
go (st, a') = do
|
||||
curro <- Annex.getState Annex.output
|
||||
(ret, st') <- liftIO $ Annex.run (st { Annex.output = curro }) $
|
||||
a `finally` stopCoProcesses
|
||||
a' `finally` stopCoProcesses
|
||||
cache st'
|
||||
return ret
|
||||
|
||||
|
|
Loading…
Reference in a new issue