Skip to content

Commit

Permalink
Add package tarball redirects for current cabal-install versions
Browse files Browse the repository at this point in the history
They expect /package/foo-1.0.tar.gz
rather than /package/foo-1.0/foo-1.0.tar.gz
  • Loading branch information
dcoutts committed Feb 23, 2012
1 parent 743c431 commit 3cfe4de
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions Distribution/Server/Features/LegacyRedirects.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ serveLegacyGets = msum
movedPermanently ("/package/" ++ display (packageId :: PackageId)) $
toResponse ""
]
, dir "package" $ path $ \fileName -> methodSP GET $
case Posix.splitExtension fileName of
(fileName', ".gz") -> case Posix.splitExtension fileName' of
(packageStr, ".tar") -> case simpleParse packageStr of
Just pkgid ->
movedPermanently (packageTarball pkgid) $ toResponse ""
_ -> mzero
_ -> mzero
_ -> mzero
]
where
-- HTTP 301 is suitable for permanently redirecting pages
Expand Down Expand Up @@ -127,11 +136,12 @@ serveArchiveTree = msum
]
]
where
packageTarball :: PackageId -> String
packageTarball pkgid = "/package/" ++ display pkgid ++ "/" ++ display pkgid ++ ".tar.gz"

docPath pkgid file = "/package/" ++ display pkgid ++ "/" ++ "doc/" ++ file

cabalPath pkgid = "/package/" ++ display pkgid ++ "/"
++ display (packageName pkgid) ++ ".cabal"

packageTarball :: PackageId -> String
packageTarball pkgid = "/package/" ++ display pkgid
++ "/" ++ display pkgid ++ ".tar.gz"

0 comments on commit 3cfe4de

Please sign in to comment.