Find implements backend.Reader
(ctx context.Context, keypath backend.KeyPath, f backend.FindFunc)
| 328 | |
| 329 | // Find implements backend.Reader |
| 330 | func (rw *readerWriter) Find(ctx context.Context, keypath backend.KeyPath, f backend.FindFunc) (err error) { |
| 331 | keypath = backend.KeyPathWithPrefix(keypath, rw.cfg.Prefix) |
| 332 | prefix := path.Join(keypath...) |
| 333 | if len(prefix) > 0 { |
| 334 | prefix += "/" |
| 335 | } |
| 336 | |
| 337 | iter := rw.bucket.Objects(ctx, &storage.Query{ |
| 338 | Delimiter: "", |
| 339 | Prefix: prefix, |
| 340 | Versions: false, |
| 341 | }) |
| 342 | |
| 343 | for { |
| 344 | attrs, iterErr := iter.Next() |
| 345 | if errors.Is(iterErr, iterator.Done) { |
| 346 | break |
| 347 | } |
| 348 | if iterErr != nil { |
| 349 | return fmt.Errorf("iterating objects: %w", err) |
| 350 | } |
| 351 | |
| 352 | opts := backend.FindMatch{ |
| 353 | Key: strings.TrimPrefix(attrs.Name, rw.cfg.Prefix), |
| 354 | Modified: attrs.Updated, |
| 355 | } |
| 356 | f(opts) |
| 357 | } |
| 358 | |
| 359 | return |
| 360 | } |
| 361 | |
| 362 | // Read implements backend.Reader |
| 363 | func (rw *readerWriter) Read(ctx context.Context, name string, keypath backend.KeyPath, _ *backend.CacheInfo) (io.ReadCloser, int64, error) { |
nothing calls this directly
no test coverage detected