Skip to content

Commit

Permalink
act on reviewer comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gbaz authored and mergify-bot committed Feb 22, 2022
1 parent 4be36fa commit c584327
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cabal-install/src/Distribution/Client/CmdUpdate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ updateRepo verbosity _updateFlags repoCtxt (repo, indexState) = do
case updated of
Sec.NoUpdates -> do
now <- getCurrentTime
setModificationTime (indexBaseName repo <.> "tar") now `catch` (\(e :: SomeException) -> warn verbosity $ "Could not set modification time of index tarball -- " ++ show e)
setModificationTime (indexBaseName repo <.> "tar") now `catchIO`
(\e -> warn verbosity $ "Could not set modification time of index tarball -- " ++ displayException e)
noticeNoWrap verbosity $
"Package list of " ++ prettyShow rname ++
" is up to date at index-state " ++ prettyShow (IndexStateTime current_ts)
Expand Down
13 changes: 7 additions & 6 deletions cabal-install/src/Distribution/Client/IndexUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ getSourcePackagesAtIndexState verbosity repoCtxt mb_idxState mb_activeRepos = do
" as explicitly requested (via command line / project configuration)"
return idxState
Nothing -> do
mb_idxState' <- readIndexTimestamp (RepoIndex repoCtxt r)
mb_idxState' <- readIndexTimestamp verbosity (RepoIndex repoCtxt r)
case mb_idxState' of
Nothing -> do
info verbosity "Using most recent state (could not read timestamp file)"
Expand Down Expand Up @@ -366,7 +366,8 @@ readRepoIndex verbosity repoCtxt repo idxState =
handleNotFound $ do
when (isRepoRemote repo) $ warnIfIndexIsOld =<< getIndexFileAge repo
-- note that if this step fails due to a bad repocache, the the procedure can still succeed by reading from the existing cache, which is updated regardless.
updateRepoIndexCache verbosity (RepoIndex repoCtxt repo) `catch` (\(e :: SomeException) -> warn verbosity $ "unable to update the repo index cache -- " ++ displayException e)
updateRepoIndexCache verbosity (RepoIndex repoCtxt repo) `catchIO`
(\e -> warn verbosity $ "unable to update the repo index cache -- " ++ displayException e)
readPackageIndexCacheFile verbosity mkAvailablePackage
(RepoIndex repoCtxt repo)
idxState
Expand Down Expand Up @@ -1055,22 +1056,22 @@ writeIndexTimestamp index st
-- timestamp you would use to revert to this version
currentIndexTimestamp :: Verbosity -> RepoContext -> Repo -> IO Timestamp
currentIndexTimestamp verbosity repoCtxt r = do
mb_is <- readIndexTimestamp (RepoIndex repoCtxt r)
mb_is <- readIndexTimestamp verbosity (RepoIndex repoCtxt r)
case mb_is of
Just (IndexStateTime ts) -> return ts
_ -> do
(_,_,isi) <- readRepoIndex verbosity repoCtxt r IndexStateHead
return (isiHeadTime isi)

-- | Read the 'IndexState' from the filesystem
readIndexTimestamp :: Index -> IO (Maybe RepoIndexState)
readIndexTimestamp index
readIndexTimestamp :: Verbosity -> Index -> IO (Maybe RepoIndexState)
readIndexTimestamp verbosity index
= fmap simpleParsec (readFile (timestampFile index))
`catchIO` \e ->
if isDoesNotExistError e
then return Nothing
else do
putStrLn $ "Warning: could not read current index timestamp: " ++ show e
warn verbosity $ "Warning: could not read current index timestamp: " ++ displayException e
return Nothing

-- | Optimise sharing of equal values inside 'Cache'
Expand Down

0 comments on commit c584327

Please sign in to comment.