@@ -23,6 +23,7 @@ import Distribution.Server.Framework.BlobStorage (BlobId)
23
23
import qualified Distribution.Server.Framework.BlobStorage as BlobStorage
24
24
import qualified Distribution.Server.Util.ServeTarball as ServerTarball
25
25
import qualified Distribution.Server.Util.DocMeta as DocMeta
26
+ import qualified Distribution.Server.Util.GZip as Gzip
26
27
import Distribution.Server.Features.BuildReports.BuildReport (PkgDetails (.. ), BuildStatus (.. ))
27
28
import Data.TarIndex (TarIndex )
28
29
import qualified Codec.Archive.Tar as Tar
@@ -46,7 +47,6 @@ import Data.Time.Clock (NominalDiffTime, diffUTCTime, getCurrentTime)
46
47
import System.Directory (getModificationTime )
47
48
import Control.Applicative
48
49
import Distribution.Server.Features.PreferredVersions
49
- import Distribution.Server.Features.PreferredVersions.State (getVersionStatus )
50
50
import Distribution.Server.Packages.Types
51
51
-- TODO:
52
52
-- 1. Write an HTML view for organizing uploads
@@ -327,8 +327,10 @@ documentationFeature name
327
327
-- \* Generate the new index
328
328
-- \* Drop the index for the old tar-file
329
329
-- \* 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
332
334
(\ content -> return (checkDocTarball pkgid content))
333
335
case mres of
334
336
Left err -> errBadRequest " Invalid documentation tarball" [MText err]
@@ -377,15 +379,15 @@ documentationFeature name
377
379
helper (pkg: pkgs) = do
378
380
hasDoc <- queryHasDocumentation (pkgInfoId pkg)
379
381
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))
382
384
else helper pkgs
383
385
384
386
helper2 [] = pure Nothing
385
387
helper2 (pkg: pkgs) = do
386
388
hasDoc <- queryHasDocumentation (pkgInfoId pkg)
387
389
if hasDoc
388
- then pure (Just (packageId pkg))
390
+ then pure (Just (packageId pkg))
389
391
else helper2 pkgs
390
392
391
393
withDocumentation :: Resource -> DynamicPath
@@ -400,7 +402,7 @@ documentationFeature name
400
402
then (var, unPackageName $ pkgName pkgid)
401
403
else e
402
404
| e@ (var, _) <- dpath ]
403
- basePkgPath = ( renderResource' self basedpath)
405
+ basePkgPath = renderResource' self basedpath
404
406
canonicalLink = show serverBaseURI ++ basePkgPath
405
407
canonicalHeader = " <" ++ canonicalLink ++ " >; rel=\" canonical\" "
406
408
@@ -484,7 +486,7 @@ checkDocTarball pkgid =
484
486
------------------------------------------------------------------------------}
485
487
486
488
mapParaM :: 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)
488
490
489
491
getFileAge :: FilePath -> IO NominalDiffTime
490
492
getFileAge file = diffUTCTime <$> getCurrentTime <*> getModificationTime file
0 commit comments