about summary refs log tree commit diff
path: root/tools/nixery/server/storage
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-10-28T17·22+0100
committerVincent Ambo <github@tazj.in>2019-10-28T21·31+0100
commit4332d38f4f1250aebc6dc3e2bf05c67559fa57e7 (patch)
treedbbdff84167aed38f782deeab7b61cdaba8bd02c /tools/nixery/server/storage
parentb60a8d007b47a5570715e7a693e1aa186032f29c (diff)
fix(server): Correctly construct filesystem paths for layer serving
Diffstat (limited to 'tools/nixery/server/storage')
-rw-r--r--tools/nixery/server/storage/filesystem.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/tools/nixery/server/storage/filesystem.go b/tools/nixery/server/storage/filesystem.go
index 60c48e932ee2..c390a4d65cfe 100644
--- a/tools/nixery/server/storage/filesystem.go
+++ b/tools/nixery/server/storage/filesystem.go
@@ -68,12 +68,14 @@ func (b *FSBackend) Move(old, new string) error {
 	return os.Rename(path.Join(b.path, old), newpath)
 }
 
-func (b *FSBackend) ServeLayer(digest string, w http.ResponseWriter) error {
-	// http.Serve* functions attempt to be a lot more clever than
-	// I want, but I also would prefer to avoid implementing error
-	// translation myself - thus a fake request is created here.
-	req := http.Request{Method: "GET"}
-	http.ServeFile(w, &req, path.Join(b.path, "sha256:"+digest))
+func (b *FSBackend) ServeLayer(digest string, r *http.Request, w http.ResponseWriter) error {
+	p := path.Join(b.path, "layers", digest)
 
+	log.WithFields(log.Fields{
+		"layer": digest,
+		"path": p,
+	}).Info("serving layer from filesystem")
+
+	http.ServeFile(w, r, p)
 	return nil
 }