summaryrefslogtreecommitdiff
path: root/utils/ghc-pkg/Main.hs
diff options
context:
space:
mode:
authorDuncan Coutts <duncan@well-typed.com>2014-08-24 23:43:40 +0100
committerEdward Z. Yang <ezyang@cs.stanford.edu>2014-08-29 12:39:05 +0100
commit42f99e99ab38314b15d5ad4bb360ed04579bdc2d (patch)
treee96db50e74cd846b3dcc77f37fe98b4b048f31d5 /utils/ghc-pkg/Main.hs
parentb00deb7ca4b3cf485252779f7515776f8f1f95b6 (diff)
downloadhaskell-42f99e99ab38314b15d5ad4bb360ed04579bdc2d.tar.gz
Address a number of Edward's code review comments
Some others addressed as part of other recent patches.
Diffstat (limited to 'utils/ghc-pkg/Main.hs')
-rw-r--r--utils/ghc-pkg/Main.hs17
1 files changed, 11 insertions, 6 deletions
diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs
index ec23eb47b2..fdb255abfe 100644
--- a/utils/ghc-pkg/Main.hs
+++ b/utils/ghc-pkg/Main.hs
@@ -590,8 +590,9 @@ getPkgDatabases verbosity modify use_user use_cache expand_vars my_flags = do
Just f -> return (Just (f, True))
fs -> return (Just (last fs, True))
- -- If the user database exists, and for "check" and all "modify" commands
- -- we will attempt to use the user db.
+ -- If the user database exists, and for "use_user" commands (which includes
+ -- "ghc-pkg check" and all commands that modify the db) we will attempt to
+ -- use the user db.
let sys_databases
| Just (user_conf,user_exists) <- mb_user_conf,
use_user || user_exists = [user_conf, global_conf]
@@ -694,8 +695,7 @@ readParseDatabase verbosity mb_user_conf modify use_cache path
e_tcache <- tryIO $ getModificationTime cache
case e_tcache of
Left ex -> do
- when ( verbosity > Normal
- || verbosity >= Normal && not modify) $
+ whenReportCacheErrors $
if isDoesNotExistError ex
then do
warn ("WARNING: cache does not exist: " ++ cache)
@@ -727,8 +727,7 @@ readParseDatabase verbosity mb_user_conf modify use_cache path
pkgs <- GhcPkg.readPackageDbForGhcPkg cache
mkPackageDB pkgs
else do
- when ( verbosity > Normal
- || verbosity >= Normal && not modify) $ do
+ whenReportCacheErrors $ do
warn ("WARNING: cache is out of date: " ++ cache)
warn ("ghc will see an old view of this " ++
"package db. Use 'ghc-pkg recache' to fix.")
@@ -741,6 +740,12 @@ readParseDatabase verbosity mb_user_conf modify use_cache path
parseSingletonPackageConf verbosity f
pkgs <- mapM doFile $ map (path </>) confs
mkPackageDB pkgs
+
+ -- We normally report cache errors for read-only commands,
+ -- since modify commands because will usually fix the cache.
+ whenReportCacheErrors =
+ when ( verbosity > Normal
+ || verbosity >= Normal && not modify)
where
mkPackageDB pkgs = do
path_abs <- absolutePath path