avoid redundant prompt for http password in git-annex get that does autoinit
autoEnableSpecialRemotes runs a subprocess, and if the uuid for a git remote has not been probed yet, that will do a http get that will prompt for a password. And then the parent process will subsequently prompt for a password when getting annexed files from the remote. So the solution is for autoEnableSpecialRemotes to run remoteList before the subprocess, which will probe for the uuid for the git remote in the same process that will later be used to get annexed files. But, Remote.Git imports Annex.Init, and Remote.List imports Remote.Git, so Annex.Init cannot import Remote.List. Had to pass remoteList into functions in Annex.Init to get around this dependency loop.
This commit is contained in:
parent
9621beabc4
commit
c62fe5e9a8
6 changed files with 44 additions and 13 deletions
|
@ -201,8 +201,8 @@ getInitializedVersion = do
|
|||
-
|
||||
- Checks repository version and handles upgrades too.
|
||||
-}
|
||||
ensureInitialized :: Annex ()
|
||||
ensureInitialized = getInitializedVersion >>= maybe needsinit checkUpgrade
|
||||
ensureInitialized :: Annex [Remote] -> Annex ()
|
||||
ensureInitialized remotelist = getInitializedVersion >>= maybe needsinit checkUpgrade
|
||||
where
|
||||
needsinit = ifM autoInitializeAllowed
|
||||
( do
|
||||
|
@ -210,7 +210,7 @@ ensureInitialized = getInitializedVersion >>= maybe needsinit checkUpgrade
|
|||
Right () -> noop
|
||||
Left e -> giveup $ show e ++ "\n" ++
|
||||
"git-annex: automatic initialization failed due to above problems"
|
||||
autoEnableSpecialRemotes
|
||||
autoEnableSpecialRemotes remotelist
|
||||
, giveup "First run: git-annex init"
|
||||
)
|
||||
|
||||
|
@ -254,13 +254,13 @@ guardSafeToUseRepo a = ifM (inRepo Git.Config.checkRepoConfigInaccessible)
|
|||
-
|
||||
- Checks repository version and handles upgrades too.
|
||||
-}
|
||||
autoInitialize :: Annex ()
|
||||
autoInitialize = getInitializedVersion >>= maybe needsinit checkUpgrade
|
||||
autoInitialize :: Annex [Remote] -> Annex ()
|
||||
autoInitialize remotelist = getInitializedVersion >>= maybe needsinit checkUpgrade
|
||||
where
|
||||
needsinit =
|
||||
whenM (initializeAllowed <&&> autoInitializeAllowed) $ do
|
||||
initialize True Nothing Nothing
|
||||
autoEnableSpecialRemotes
|
||||
autoEnableSpecialRemotes remotelist
|
||||
|
||||
{- Checks if a repository is initialized. Does not check version for ugrade. -}
|
||||
isInitialized :: Annex Bool
|
||||
|
@ -440,9 +440,17 @@ fixupUnusualReposAfterInit = do
|
|||
{- Try to enable any special remotes that are configured to do so.
|
||||
-
|
||||
- The enabling is done in a child process to avoid it using stdio.
|
||||
-
|
||||
- The remotelist should be Remote.List.remoteList, which cannot
|
||||
- be imported here due to a dependency loop.
|
||||
-}
|
||||
autoEnableSpecialRemotes :: Annex ()
|
||||
autoEnableSpecialRemotes = do
|
||||
autoEnableSpecialRemotes :: Annex [Remote] -> Annex ()
|
||||
autoEnableSpecialRemotes remotelist = do
|
||||
-- Get all existing git remotes to probe for their uuid here,
|
||||
-- so it is not done inside the child process. Doing it in there
|
||||
-- could result in password prompts for http credentials,
|
||||
-- which would then not end up cached in this process's state.
|
||||
_ <- remotelist
|
||||
rp <- fromRawFilePath <$> fromRepo Git.repoPath
|
||||
withNullHandle $ \nullh -> gitAnnexChildProcess "init"
|
||||
[ Param "--autoenable" ]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue