(ctx context.Context, cache blobserver.Storage, thumbBytes []byte, name string)
| 93 | } |
| 94 | |
| 95 | func writeToCache(ctx context.Context, cache blobserver.Storage, thumbBytes []byte, name string) (br blob.Ref, err error) { |
| 96 | tr := bytes.NewReader(thumbBytes) |
| 97 | if len(thumbBytes) < constants.MaxBlobSize { |
| 98 | br = blob.RefFromBytes(thumbBytes) |
| 99 | _, err = blobserver.Receive(ctx, cache, br, tr) |
| 100 | } else { |
| 101 | // TODO: don't use rolling checksums when writing this. Tell |
| 102 | // the filewriter to use 16 MB chunks instead. |
| 103 | br, err = schema.WriteFileFromReader(ctx, cache, name, tr) |
| 104 | } |
| 105 | if err != nil { |
| 106 | return br, errors.New("failed to cache " + name + ": " + err.Error()) |
| 107 | } |
| 108 | if imageDebug { |
| 109 | log.Printf("Image Cache: saved as %v\n", br) |
| 110 | } |
| 111 | return br, nil |
| 112 | } |
| 113 | |
| 114 | // cacheScaled saves in the image handler's cache the scaled image bytes |
| 115 | // in thumbBytes, and puts its blobref in the scaledImage under the key name. |
no test coverage detected