Find implements backend.Reader
(ctx context.Context, keypath backend.KeyPath, f backend.FindFunc)
| 503 | |
| 504 | // Find implements backend.Reader |
| 505 | func (rw *readerWriter) Find(ctx context.Context, keypath backend.KeyPath, f backend.FindFunc) (err error) { |
| 506 | keypath = backend.KeyPathWithPrefix(keypath, rw.cfg.Prefix) |
| 507 | prefix := path.Join(keypath...) |
| 508 | |
| 509 | if len(prefix) > 0 { |
| 510 | prefix += "/" |
| 511 | } |
| 512 | |
| 513 | nextToken := "" |
| 514 | isTruncated := true |
| 515 | var res minio.ListBucketV2Result |
| 516 | |
| 517 | for isTruncated { |
| 518 | select { |
| 519 | case <-ctx.Done(): |
| 520 | return |
| 521 | default: |
| 522 | res, err = rw.core.ListObjectsV2(rw.cfg.Bucket, prefix, "", nextToken, "", 0) |
| 523 | if err != nil { |
| 524 | return fmt.Errorf("error finding objects in s3 bucket, bucket: %s: %w", rw.cfg.Bucket, err) |
| 525 | } |
| 526 | |
| 527 | isTruncated = res.IsTruncated |
| 528 | nextToken = res.NextContinuationToken |
| 529 | |
| 530 | if len(res.Contents) > 0 { |
| 531 | for _, c := range res.Contents { |
| 532 | opts := backend.FindMatch{ |
| 533 | Key: strings.TrimPrefix(c.Key, rw.cfg.Prefix), |
| 534 | Modified: c.LastModified, |
| 535 | } |
| 536 | f(opts) |
| 537 | } |
| 538 | } |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | return |
| 543 | } |
| 544 | |
| 545 | // Read implements backend.Reader |
| 546 | 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