@@ -23,6 +23,7 @@ import Distribution.Server.Framework.BlobStorage (BlobId)
2323import qualified Distribution.Server.Framework.BlobStorage as BlobStorage
2424import qualified Distribution.Server.Util.ServeTarball as ServerTarball
2525import qualified Distribution.Server.Util.DocMeta as DocMeta
26+ import qualified Distribution.Server.Util.GZip as Gzip
2627import Distribution.Server.Features.BuildReports.BuildReport (PkgDetails (.. ), BuildStatus (.. ))
2728import Data.TarIndex (TarIndex )
2829import qualified Codec.Archive.Tar as Tar
@@ -46,7 +47,6 @@ import Data.Time.Clock (NominalDiffTime, diffUTCTime, getCurrentTime)
4647import System.Directory (getModificationTime )
4748import Control.Applicative
4849import Distribution.Server.Features.PreferredVersions
49- import Distribution.Server.Features.PreferredVersions.State (getVersionStatus )
5050import Distribution.Server.Packages.Types
5151-- TODO:
5252-- 1. Write an HTML view for organizing uploads
@@ -327,8 +327,10 @@ documentationFeature name
327327 -- \* Generate the new index
328328 -- \* Drop the index for the old tar-file
329329 -- \* Link the new documentation to the package
330- fileContents <- expectUncompressedTarball
331- mres <- liftIO $ BlobStorage. addWith store fileContents
330+ fileContents <- expectCompressedTarball
331+ let filename = display pkgid ++ " -docs" <.> " tar.gz"
332+ unpacked = Gzip. decompressNamed filename fileContents
333+ mres <- liftIO $ BlobStorage. addWith store unpacked
332334 (\ content -> return (checkDocTarball pkgid content))
333335 case mres of
334336 Left err -> errBadRequest " Invalid documentation tarball" [MText err]
@@ -377,15 +379,15 @@ documentationFeature name
377379 helper (pkg: pkgs) = do
378380 hasDoc <- queryHasDocumentation (pkgInfoId pkg)
379381 let status = getVersionStatus prefInfo (packageVersion pkg)
380- if hasDoc && status == NormalVersion
381- then pure (Just (packageId pkg))
382+ if hasDoc && status == NormalVersion
383+ then pure (Just (packageId pkg))
382384 else helper pkgs
383385
384386 helper2 [] = pure Nothing
385387 helper2 (pkg: pkgs) = do
386388 hasDoc <- queryHasDocumentation (pkgInfoId pkg)
387389 if hasDoc
388- then pure (Just (packageId pkg))
390+ then pure (Just (packageId pkg))
389391 else helper2 pkgs
390392
391393 withDocumentation :: Resource -> DynamicPath
@@ -400,7 +402,7 @@ documentationFeature name
400402 then (var, unPackageName $ pkgName pkgid)
401403 else e
402404 | e@ (var, _) <- dpath ]
403- basePkgPath = ( renderResource' self basedpath)
405+ basePkgPath = renderResource' self basedpath
404406 canonicalLink = show serverBaseURI ++ basePkgPath
405407 canonicalHeader = " <" ++ canonicalLink ++ " >; rel=\" canonical\" "
406408
@@ -484,7 +486,7 @@ checkDocTarball pkgid =
484486------------------------------------------------------------------------------}
485487
486488mapParaM :: Monad m => (a -> m b ) -> [a ] -> m [(a , b )]
487- mapParaM f = mapM (\ x -> (,) x `liftM` f x)
489+ mapParaM f = mapM (\ x -> (,) x <$> f x)
488490
489491getFileAge :: FilePath -> IO NominalDiffTime
490492getFileAge file = diffUTCTime <$> getCurrentTime <*> getModificationTime file
0 commit comments