[commit: packages/Cabal] ghc-head: Fix the 'index.cache' up-to-date check. (0bd367f)
git at git.haskell.org
git at git.haskell.org
Thu Aug 29 10:12:10 CEST 2013
Repository : ssh://git@git.haskell.org/Cabal
On branch : ghc-head
Link : http://git.haskell.org/?p=packages/Cabal.git;a=commit;h=0bd367f63498f330297b94bb814d7eea664a8a7e
>---------------------------------------------------------------
commit 0bd367f63498f330297b94bb814d7eea664a8a7e
Author: Mikhail Glushenkov <mikhail.glushenkov at gmail.com>
Date: Wed Aug 28 00:21:55 2013 +0200
Fix the 'index.cache' up-to-date check.
Comparison was using (>) instead of (>=). Bug introduced in 272a5c2c.
Fixes #1443.
>---------------------------------------------------------------
0bd367f63498f330297b94bb814d7eea664a8a7e
cabal-install/Distribution/Client/IndexUtils.hs | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/cabal-install/Distribution/Client/IndexUtils.hs b/cabal-install/Distribution/Client/IndexUtils.hs
index 80ce53e..5fce416 100644
--- a/cabal-install/Distribution/Client/IndexUtils.hs
+++ b/cabal-install/Distribution/Client/IndexUtils.hs
@@ -55,7 +55,7 @@ import Distribution.Text
import Distribution.Verbosity
( Verbosity, normal, lessVerbose )
import Distribution.Simple.Utils
- ( die, warn, info, fromUTF8, findPackageDesc, moreRecentFile )
+ ( die, warn, info, fromUTF8, findPackageDesc )
import Data.Char (isAlphaNum)
import Data.Maybe (mapMaybe, fromMaybe)
@@ -72,6 +72,7 @@ import Distribution.Client.GZipUtils (maybeDecompress)
import Distribution.Client.Utils (byteStringToFilePath)
import Distribution.Compat.Exception (catchIO)
import Distribution.Client.Compat.Time
+import System.Directory (doesFileExist)
import System.FilePath ((</>), takeExtension, splitDirectories, normalise)
import System.FilePath.Posix as FilePath.Posix
( takeFileName )
@@ -234,9 +235,13 @@ updateRepoIndexCache verbosity repo =
whenCacheOutOfDate :: FilePath -> FilePath -> IO () -> IO ()
whenCacheOutOfDate origFile cacheFile action = do
- cacheOutOfDate <- origFile `moreRecentFile` cacheFile
- when cacheOutOfDate action
-
+ exists <- doesFileExist cacheFile
+ if not exists
+ then action
+ else do
+ origTime <- getModTime origFile
+ cacheTime <- getModTime cacheFile
+ when (origTime >= cacheTime) action
------------------------------------------------------------------------
-- Reading the index file
More information about the ghc-commits
mailing list