about summary refs log tree commit diff
path: root/tools/nixery/server
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-10-01T22·26+0100
committerVincent Ambo <github@tazj.in>2019-10-03T12·21+0100
commit17adda03552d44b6354c3a801614559975c82144 (patch)
treef24963838b31d59c6d0ff17ab4579cc914732a2b /tools/nixery/server
parentef2623d168fc3f91020fdb574f5287b01d7534e6 (diff)
fix(server): Minor fixes to updated new builder code
Diffstat (limited to 'tools/nixery/server')
-rw-r--r--tools/nixery/server/builder/cache.go11
-rw-r--r--tools/nixery/server/main.go4
2 files changed, 7 insertions, 8 deletions
diff --git a/tools/nixery/server/builder/cache.go b/tools/nixery/server/builder/cache.go
index edb1b711d853..254f32d8306d 100644
--- a/tools/nixery/server/builder/cache.go
+++ b/tools/nixery/server/builder/cache.go
@@ -52,6 +52,7 @@ func NewCache() LocalCache {
 	return LocalCache{
 		mcache: make(map[string]string),
 		lcache: make(map[string]void),
+		bcache: make(map[string]Build),
 	}
 }
 
@@ -111,7 +112,7 @@ func (c *LocalCache) localCacheBuild(key string, b Build) {
 
 // Retrieve a manifest from the cache(s). First the local cache is
 // checked, then the GCS-bucket cache.
-func manifestFromCache(ctx *context.Context, cache *LocalCache, bucket *storage.BucketHandle, key string) (string, bool) {
+func manifestFromCache(ctx context.Context, cache *LocalCache, bucket *storage.BucketHandle, key string) (string, bool) {
 	path, cached := cache.manifestFromLocalCache(key)
 	if cached {
 		return path, true
@@ -120,12 +121,12 @@ func manifestFromCache(ctx *context.Context, cache *LocalCache, bucket *storage.
 	obj := bucket.Object("manifests/" + key)
 
 	// Probe whether the file exists before trying to fetch it.
-	_, err := obj.Attrs(*ctx)
+	_, err := obj.Attrs(ctx)
 	if err != nil {
 		return "", false
 	}
 
-	r, err := obj.NewReader(*ctx)
+	r, err := obj.NewReader(ctx)
 	if err != nil {
 		log.Printf("Failed to retrieve manifest '%s' from cache: %s\n", key, err)
 		return "", false
@@ -222,11 +223,9 @@ func cacheBuild(ctx context.Context, cache *LocalCache, bucket *storage.BucketHa
 
 	w := obj.NewWriter(ctx)
 
-	size, err := io.Copy(w, bytes.NewReader(j))
+	_, err := io.Copy(w, bytes.NewReader(j))
 	if err != nil {
 		log.Printf("failed to cache build '%s': %s\n", key, err)
 		return
 	}
-
-	log.Printf("cached build '%s' (%v bytes written)\n", key, size)
 }
diff --git a/tools/nixery/server/main.go b/tools/nixery/server/main.go
index ae8dd3ab2dbf..c3a0b6460a39 100644
--- a/tools/nixery/server/main.go
+++ b/tools/nixery/server/main.go
@@ -122,7 +122,7 @@ func writeError(w http.ResponseWriter, status int, code, message string) {
 }
 
 type registryHandler struct {
-	ctx   *context.Context
+	ctx   context.Context
 	state *builder.State
 }
 
@@ -201,7 +201,7 @@ func main() {
 
 	// All /v2/ requests belong to the registry handler.
 	http.Handle("/v2/", &registryHandler{
-		ctx:   &ctx,
+		ctx:   ctx,
 		state: &state,
 	})