Skip to content

Commit

Permalink
Gracefully handle leftover single file inplace databases, fixes #2320
Browse files Browse the repository at this point in the history
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
  • Loading branch information
ezyang committed Jan 5, 2015
1 parent 361b2b0 commit 3948f26
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Cabal/Distribution/Simple/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ import Control.Monad
import System.FilePath
( (</>), (<.>) )
import System.Directory
( getCurrentDirectory, removeDirectoryRecursive, doesDirectoryExist )
( getCurrentDirectory, removeDirectoryRecursive, removeFile
, doesDirectoryExist, doesFileExist )

-- -----------------------------------------------------------------------------
-- |Build the libraries and executables in this package.
Expand Down Expand Up @@ -452,8 +453,11 @@ createInternalPackageDB verbosity lbi distPref = do
dbDir = distPref </> "package.conf.inplace"
packageDB = SpecificPackageDB dbDir
createWith hpi = do
exists <- doesDirectoryExist dbDir
when exists $ removeDirectoryRecursive dbDir
dir_exists <- doesDirectoryExist dbDir
if dir_exists
then removeDirectoryRecursive dbDir
else do file_exists <- doesFileExist dbDir
when file_exists $ removeFile dbDir
HcPkg.init hpi verbosity dbDir
return packageDB

Expand Down

0 comments on commit 3948f26

Please sign in to comment.