Skip to content
Snippets Groups Projects
Commit 54e1ed29 authored by Łukasz Dąbek's avatar Łukasz Dąbek
Browse files

Made parsePackageIndex and updatePackageIndexCacheFile streaming.

The parsePackageIndex wasn't streaming because resulting list was
hidden in two constructors: Either and tuple. By removing that error
semantics changed in updatePackageIndexCacheFile.

The updatePackageIndexCacheFile problem was sequence call that evaluated
whole list made by parsePackageIndex. By using lazySequence any error
during index file parsing will be raised during writing to cache file.

Also removed reacPackageIndexFile, as it wasn't used anywhere as far as
I can tell. If this is a mistake I'll include it again.
parent fbf2298e
No related branches found
No related tags found
No related merge requests found
......@@ -288,33 +288,6 @@ packageDesc :: PackageEntry -> GenericPackageDescription
packageDesc (NormalPackage _ descr _ _) = descr
packageDesc (BuildTreeRef _ _ descr _ _) = descr
-- | Read a compressed \"00-index.tar.gz\" file into a 'PackageIndex'.
--
-- This is supposed to be an \"all in one\" way to easily get at the info in
-- the Hackage package index.
--
-- It takes a function to map a 'GenericPackageDescription' into any more
-- specific instance of 'Package' that you might want to use. In the simple
-- case you can just use @\_ p -> p@ here.
--
{-
readPackageIndexFile :: Package pkg
=> (PackageEntry -> pkg)
-> FilePath
-> IO (PackageIndex pkg, [Dependency])
readPackageIndexFile mkPkg indexFile = do
(mkPkgs, prefs) <- either fail return
. parsePackageIndex
. maybeDecompress
=<< BS.readFile indexFile
pkgEntries <- sequence mkPkgs
pkgs <- evaluate $ PackageIndex.fromList (map mkPkg pkgEntries)
return (pkgs, prefs)
-}
-- | Parse an uncompressed \"00-index.tar\" repository index file represented
-- as a 'ByteString'.
--
......@@ -413,15 +386,13 @@ updatePackageIndexCacheFile verbosity indexFile cacheFile = do
. maybeDecompress
=<< BS.readFile indexFile
entries <- lazySequence pkgsOrPrefs
let cache = mkCache entries
let cache = map toCache entries
writeFile cacheFile (showIndexCache cache)
where
toCache (Pkg (NormalPackage pkgid _ _ blockNo)) = CachePackageId pkgid blockNo
toCache (Pkg (BuildTreeRef refType _ _ _ blockNo)) = CacheBuildTreeRef refType blockNo
toCache (Dep d) = CachePreference d
mkCache = map toCache
data ReadPackageIndexMode = ReadPackageIndexStrict
| ReadPackageIndexLazyIO
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment