(ctx context.Context, in rc.Params)
| 681 | } |
| 682 | |
| 683 | func (f *Fs) rcFetch(ctx context.Context, in rc.Params) (rc.Params, error) { |
| 684 | type chunkRange struct { |
| 685 | start, end int64 |
| 686 | } |
| 687 | parseChunks := func(ranges string) (crs []chunkRange, err error) { |
| 688 | for part := range strings.SplitSeq(ranges, ",") { |
| 689 | var start, end int64 = 0, math.MaxInt64 |
| 690 | switch ints := strings.Split(part, ":"); len(ints) { |
| 691 | case 1: |
| 692 | start, err = strconv.ParseInt(ints[0], 10, 64) |
| 693 | if err != nil { |
| 694 | return nil, fmt.Errorf("invalid range: %q", part) |
| 695 | } |
| 696 | end = start + 1 |
| 697 | case 2: |
| 698 | if ints[0] != "" { |
| 699 | start, err = strconv.ParseInt(ints[0], 10, 64) |
| 700 | if err != nil { |
| 701 | return nil, fmt.Errorf("invalid range: %q", part) |
| 702 | } |
| 703 | } |
| 704 | if ints[1] != "" { |
| 705 | end, err = strconv.ParseInt(ints[1], 10, 64) |
| 706 | if err != nil { |
| 707 | return nil, fmt.Errorf("invalid range: %q", part) |
| 708 | } |
| 709 | } |
| 710 | default: |
| 711 | return nil, fmt.Errorf("invalid range: %q", part) |
| 712 | } |
| 713 | crs = append(crs, chunkRange{start: start, end: end}) |
| 714 | } |
| 715 | return |
| 716 | } |
| 717 | walkChunkRange := func(cr chunkRange, size int64, cb func(chunk int64)) { |
| 718 | if size <= 0 { |
| 719 | return |
| 720 | } |
| 721 | chunks := (size-1)/f.ChunkSize() + 1 |
| 722 | |
| 723 | start, end := cr.start, cr.end |
| 724 | if start < 0 { |
| 725 | start += chunks |
| 726 | } |
| 727 | if end <= 0 { |
| 728 | end += chunks |
| 729 | } |
| 730 | if end <= start { |
| 731 | return |
| 732 | } |
| 733 | switch { |
| 734 | case start < 0: |
| 735 | start = 0 |
| 736 | case start >= chunks: |
| 737 | return |
| 738 | } |
| 739 | switch { |
| 740 | case end <= start: |
nothing calls this directly
no test coverage detected