1
0
Fork 0
mirror of https://github.com/imjasonh/kontain.me synced 2026-07-18 23:03:06 +00:00

write alsos concurrently

This commit is contained in:
Jason Hall 2020-12-30 06:00:35 -05:00
parent 24156a249e
commit ad7448ad40

View file

@ -111,10 +111,14 @@ func Index(w http.ResponseWriter, r *http.Request, idx v1.ImageIndex, also ...st
}
for _, a := range also {
log.Printf("writing index manifest %q also to %q", digest, a)
if err := writeBlob(a, digest, ioutil.NopCloser(bytes.NewReader(b)), string(mt)); err != nil {
return err
}
a := a
g.Go(func() error {
log.Printf("writing index manifest %q also to %q", digest, a)
return writeBlob(a, digest, ioutil.NopCloser(bytes.NewReader(b)), string(mt))
})
}
if err := g.Wait(); err != nil {
return err
}
// Redirect to manifest blob.
@ -181,11 +185,13 @@ func writeImage(img v1.Image, also ...string) error {
return err
}
for _, a := range also {
log.Printf("writing image manifest %q also to %q", digest, a)
if err := writeBlob(a, digest, ioutil.NopCloser(bytes.NewReader(b)), string(mt)); err != nil {
return err
}
a := a
g.Go(func() error {
log.Printf("writing image manifest %q also to %q", digest, a)
return writeBlob(a, digest, ioutil.NopCloser(bytes.NewReader(b)), string(mt))
})
}
return g.Wait()
return nil
}