Hide the mirror's bookkeeping, bound GGUF array nesting, and forget old serve jobs and downloads

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-04 10:56:16 +02:00
1 parent fdd4dcf841
commit 7e57863edd
10 files changed
+151 -3

No files matched your search

+8
View File
@@ -388,6 +388,14 @@ func readOnly(h http.Handler) http.Handler {
http.Error(w, "the mirror is read-only", http.StatusMethodNotAllowed)
return
}
// The mirror's own bookkeeping — a file's checksum, the URL it came
// from — sits beside it under a dot, and is nobody's to download.
for _, seg := range strings.Split(r.URL.Path, "/") {
if strings.HasPrefix(seg, ".") {
http.NotFound(w, r)
return
}
}
h.ServeHTTP(w, r)
})
}
+21
View File
@@ -72,3 +72,24 @@ func TestAVersionAnswersHeadAsWellAsGet(t *testing.T) {
t.Errorf("expected a manifest, got %q", got)
}
}
func TestTheMirrorDoesNotServeItsBookkeeping(t *testing.T) {
root := t.TempDir()
dir := filepath.Join(root, "llama", "v1")
_ = os.MkdirAll(dir, 0o755)
_ = os.WriteFile(filepath.Join(dir, "m.gguf"), []byte("x"), 0o644)
_ = os.WriteFile(filepath.Join(dir, ".m.gguf.source"), []byte("https://example.com/m.gguf\n"), 0o644)
h := readOnly(withManifest(root, http.FileServer(http.Dir(root))))
for path, want := range map[string]int{
"/llama/v1/m.gguf": http.StatusOK,
"/llama/v1/.m.gguf.source": http.StatusNotFound,
"/llama/.hidden/x": http.StatusNotFound,
} {
w := httptest.NewRecorder()
h.ServeHTTP(w, httptest.NewRequest(http.MethodGet, path, nil))
if w.Code != want {
t.Errorf("%s: %d, expected %d", path, w.Code, want)
}
}
}