Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If git fetch fails wipe the directory and try again from scratch #1580

Merged
merged 3 commits into from
Jan 3, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/Stack/PackageIndex.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}

-- | Dealing with the 00-index file and all its cabal files.
module Stack.PackageIndex
Expand Down Expand Up @@ -64,7 +65,8 @@ import Stack.Types.StackT
import System.FilePath (takeBaseName, (<.>))
import System.IO (IOMode (ReadMode, WriteMode),
withBinaryFile)
import System.Process.Read (readInNull, EnvOverride, doesExecutableExist)
import System.Process.Read (readInNull, readProcessNull, ReadProcessException(..),
EnvOverride, doesExecutableExist)

-- | Populate the package index caches and return them.
populateCache
Expand Down Expand Up @@ -243,7 +245,14 @@ updateIndexGit menv indexName' index gitUrl = do
unless repoExists
(readInNull suDir "git" menv cloneArgs Nothing)
$logSticky "Fetching package index ..."
readInNull acfDir "git" menv ["fetch","--tags","--depth=1"] Nothing
readProcessNull (Just acfDir) menv "git" ["fetch","--tags","--depth=1"] `C.catch` \(ex :: ReadProcessException) -> do
-- we failed, so wipe the directory and try again, see #1418
$logWarn (T.pack (show ex))
$logStickyDone "Failed to fetch package index, retrying."
removeTree acfDir
readInNull suDir "git" menv cloneArgs Nothing
$logSticky "Fetching package index ..."
readInNull acfDir "git" menv ["fetch","--tags","--depth=1"] Nothing
$logStickyDone "Fetched package index."
removeFileIfExists tarFile
when (indexGpgVerify index)
Expand Down