loadFromCache will try to load the file from the cache.
(h backend.Handle, length int, offset int64, consumer func(rd io.Reader) error)
| 137 | |
| 138 | // loadFromCache will try to load the file from the cache. |
| 139 | func (b *Backend) loadFromCache(h backend.Handle, length int, offset int64, consumer func(rd io.Reader) error) (bool, error) { |
| 140 | rd, inCache, err := b.Cache.load(h, length, offset) |
| 141 | if err != nil { |
| 142 | return inCache, err |
| 143 | } |
| 144 | |
| 145 | err = consumer(rd) |
| 146 | if err != nil { |
| 147 | _ = rd.Close() // ignore secondary errors |
| 148 | return true, err |
| 149 | } |
| 150 | return true, rd.Close() |
| 151 | } |
| 152 | |
| 153 | // Load loads a file from the cache or the backend. |
| 154 | func (b *Backend) Load(ctx context.Context, h backend.Handle, length int, offset int64, consumer func(rd io.Reader) error) error { |
no test coverage detected