Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3cfe4de

Browse filesBrowse files
committed
Add package tarball redirects for current cabal-install versions
They expect /package/foo-1.0.tar.gz rather than /package/foo-1.0/foo-1.0.tar.gz
1 parent 743c431 commit 3cfe4de
Copy full SHA for 3cfe4de

1 file changed

+13-3Lines changed: 13 additions & 3 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Distribution/Server/Features/LegacyRedirects.hs‎

Copy file name to clipboardExpand all lines: Distribution/Server/Features/LegacyRedirects.hs
+13-3Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ serveLegacyGets = msum
7272
movedPermanently ("/package/" ++ display (packageId :: PackageId)) $
7373
toResponse ""
7474
]
75+
, dir "package" $ path $ \fileName -> methodSP GET $
76+
case Posix.splitExtension fileName of
77+
(fileName', ".gz") -> case Posix.splitExtension fileName' of
78+
(packageStr, ".tar") -> case simpleParse packageStr of
79+
Just pkgid ->
80+
movedPermanently (packageTarball pkgid) $ toResponse ""
81+
_ -> mzero
82+
_ -> mzero
83+
_ -> mzero
7584
]
7685
where
7786
-- HTTP 301 is suitable for permanently redirecting pages
@@ -127,11 +136,12 @@ serveArchiveTree = msum
127136
]
128137
]
129138
where
130-
packageTarball :: PackageId -> String
131-
packageTarball pkgid = "/package/" ++ display pkgid ++ "/" ++ display pkgid ++ ".tar.gz"
132-
133139
docPath pkgid file = "/package/" ++ display pkgid ++ "/" ++ "doc/" ++ file
134140

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

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.