[commit: Cabal] master: Tweak implementation of fetchRepoTarball (068de9c)
Ian Lynagh
igloo at earth.li
Fri Jun 24 02:07:41 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/Cabal
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/068de9c410360c326a3ba906af4d5d3feaa270f4
>---------------------------------------------------------------
commit 068de9c410360c326a3ba906af4d5d3feaa270f4
Author: Duncan Coutts <duncan at community.haskell.org>
Date: Sun Feb 13 20:01:09 2011 +0000
Tweak implementation of fetchRepoTarball
>---------------------------------------------------------------
cabal-install/Distribution/Client/FetchUtils.hs | 29 ++++++++++------------
1 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/cabal-install/Distribution/Client/FetchUtils.hs b/cabal-install/Distribution/Client/FetchUtils.hs
index fb3968b..ed807c0 100644
--- a/cabal-install/Distribution/Client/FetchUtils.hs
+++ b/cabal-install/Distribution/Client/FetchUtils.hs
@@ -31,7 +31,7 @@ import Distribution.Client.HttpUtils
import Distribution.Package
( PackageId, packageName, packageVersion )
import Distribution.Simple.Utils
- ( notice, info, debug, setupMessage )
+ ( notice, info, setupMessage )
import Distribution.Text
( display )
import Distribution.Verbosity
@@ -104,21 +104,18 @@ fetchRepoTarball verbosity repo pkgid = do
then do info verbosity $ display pkgid ++ " has already been downloaded."
return (packageFile repo pkgid)
else do setupMessage verbosity "Downloading" pkgid
- downloadPackage verbosity repo pkgid
-
--- Downloads a package to [config-dir/packages/package-id] and returns the path to the package.
-downloadPackage :: Verbosity -> Repo -> PackageId -> IO String
-downloadPackage _ repo at Repo{ repoKind = Right LocalRepo } pkgid =
- return (packageFile repo pkgid)
-
-downloadPackage verbosity repo at Repo{ repoKind = Left remoteRepo } pkgid = do
- let uri = packageURI remoteRepo pkgid
- dir = packageDir repo pkgid
- path = packageFile repo pkgid
- debug verbosity $ "GET " ++ show uri
- createDirectoryIfMissing True dir
- downloadURI verbosity uri path
- return path
+ downloadRepoPackage
+ where
+ downloadRepoPackage = case repoKind repo of
+ Right LocalRepo -> return (packageFile repo pkgid)
+
+ Left remoteRepo -> do
+ let uri = packageURI remoteRepo pkgid
+ dir = packageDir repo pkgid
+ path = packageFile repo pkgid
+ createDirectoryIfMissing True dir
+ downloadURI verbosity uri path
+ return path
-- | Downloads an index file to [config-dir/packages/serv-id].
--
More information about the Cvs-libraries
mailing list