Repository navigation
fix(debian): route packages by filename rather than /pool prefix
#672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,11 +108,13 @@ func (h *DebianHandler) Routes() http.Handler { | |
| } | ||
| } | ||
|
|
||
| // Route based on path type | ||
| // Route by filename rather than path prefix because flat repositories | ||
| // place pools under dists/<suite>/pool/.... | ||
| switch { | ||
| case strings.HasPrefix(rest, "pool/"): | ||
| // Package downloads - cache these | ||
| case isDebPackageFile(rest): | ||
| h.handlePackageDownload(w, r, repository, upstreamURL, rest) | ||
| case isSourcePackageFile(rest): | ||
| h.proxyFile(w, r, upstreamURL, rest) | ||
|
Comment on lines
+114
to
+117
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| case strings.HasPrefix(rest, "dists/"): | ||
| // Repository metadata - served through the metadata cache | ||
| h.handleMetadata(w, r, repository, upstreamURL, rest) | ||
|
|
@@ -123,6 +125,26 @@ func (h *DebianHandler) Routes() http.Handler { | |
| })) | ||
| } | ||
|
|
||
| func isDebPackageFile(path string) bool { | ||
| return strings.HasSuffix(path, ".deb") | ||
| } | ||
|
|
||
| // isSourcePackageFile reports whether path is a Debian source-package artifact. | ||
| // Source files can be re-uploaded or re-signed in place under the same filename, | ||
| // so they must be streamed rather than cached without digest verification. | ||
| func isSourcePackageFile(path string) bool { | ||
| switch { | ||
| case strings.HasSuffix(path, ".dsc"), | ||
| strings.HasSuffix(path, ".buildinfo"), | ||
| strings.HasSuffix(path, ".changes"): | ||
| return true | ||
| } | ||
| // Match Debian source tarballs without matching suite tarballs (e.g. installer netboot.tar.gz). | ||
| return strings.Contains(path, ".orig.tar.") || | ||
| strings.Contains(path, ".orig-") || | ||
| strings.Contains(path, ".debian.tar.") | ||
| } | ||
|
|
||
| // repositoryNotFound answers a request addressed to a repository that is not | ||
| // configured, naming the ones that are so a misspelling is self-evident. | ||
| func (h *DebianHandler) repositoryNotFound(w http.ResponseWriter, name string) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: git-pkgs/proxy
Length of output: 9047
Script executed:
Repository: git-pkgs/proxy
Length of output: 31183
Script executed:
Repository: git-pkgs/proxy
Length of output: 10899
Cache root-level Debian packages
For
/debian/{repository}/package_1_amd64.deb,parsePoolPathrejects the filename because it has no slash. The handler then proxies it without caching, so repeated requests reach the upstream archive. Parse the filename even when the path has no directory, and add a root-level caching test.Suggested fix