summaryrefslogtreecommitdiff
path: root/Remote
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-07-15 14:27:43 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-07-15 14:27:43 -0400
commitc94a5d86b80dd06a018689da551012bf7d608dec (patch)
tree1616e477ff19d38a45e09258eb4facba11b9f895 /Remote
parentb5d944968aee1390bbcbcb36f96e26d8a0a5c9dd (diff)
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.
Diffstat (limited to 'Remote')
-rw-r--r--Remote/Git.hs22
1 files changed, 11 insertions, 11 deletions
diff --git a/Remote/Git.hs b/Remote/Git.hs
index 5dcd3bf15..6308f5cd6 100644
--- a/Remote/Git.hs
+++ b/Remote/Git.hs
@@ -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.