sync: Fix git sync with local git remotes even when they don't have an annex.uuid set.
Catch an exception when ensureInitialized is run in a non-initted repository. In this case, just read the git config, so that the Git.Repo object is not LocalUnknown, which is what is used to represent remotes on eg, drives that are not connected. The assistant already got this right, and like with the assistant, this causes an implicit git-annex init of the local remote on the second sync, once the git-annex branch has been pushed to it. See this comment for more analysis: http://git-annex.branchable.com/todo/Recovering_from_a_bad_sync/#comment-64e469a2c1969829ee149cbb41b1c138 This commit was sponsored by jscit.
This commit is contained in:
parent
a3d73a2cb3
commit
522a0922b8
4 changed files with 19 additions and 15 deletions
|
@ -191,20 +191,11 @@ tryGitConfigRead r
|
|||
| Git.repoIsHttp r = store geturlconfig
|
||||
| Git.GCrypt.isEncrypted r = handlegcrypt =<< getConfigMaybe (remoteConfig r "uuid")
|
||||
| Git.repoIsUrl r = return r
|
||||
| otherwise = store $ safely $ do
|
||||
s <- Annex.new r
|
||||
Annex.eval s $ do
|
||||
Annex.BranchState.disableUpdate
|
||||
ensureInitialized
|
||||
Annex.getState Annex.repo
|
||||
| otherwise = store $ liftIO $
|
||||
readlocalannexconfig `catchNonAsync` (const $ Git.Config.read r)
|
||||
where
|
||||
haveconfig = not . M.null . Git.config
|
||||
|
||||
-- Reading config can fail due to IO error or
|
||||
-- for other reasons; catch all possible exceptions.
|
||||
safely a = either (const $ return r) return
|
||||
=<< liftIO (try a :: IO (Either SomeException Git.Repo))
|
||||
|
||||
pipedconfig cmd params = do
|
||||
v <- Git.Config.fromPipe r cmd params
|
||||
case v of
|
||||
|
@ -283,6 +274,15 @@ tryGitConfigRead r
|
|||
Just v -> store $ liftIO $ setUUID r $
|
||||
genUUIDInNameSpace gCryptNameSpace v
|
||||
|
||||
{- Throws an exception if the remote is not already initialied
|
||||
- or cannot be automatically initialized. -}
|
||||
readlocalannexconfig = do
|
||||
s <- Annex.new r
|
||||
Annex.eval s $ do
|
||||
Annex.BranchState.disableUpdate
|
||||
ensureInitialized
|
||||
Annex.getState Annex.repo
|
||||
|
||||
{- Checks if a given remote has the content for a key inAnnex.
|
||||
- If the remote cannot be accessed, or if it cannot determine
|
||||
- whether it has the content, returns a Left error message.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue