Skip to content

Commit

Permalink
Merge branch 'main' into iter-object-attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
fpetkovski authored Oct 31, 2024
2 parents ac8779f + 8648e8e commit 27782a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions objstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ func TryToGetSize(r io.Reader) (int64, error) {
return f.Size(), nil
case ObjectSizer:
return f.ObjectSize()
case *io.LimitedReader:
return f.N, nil
}
return 0, errors.Errorf("unsupported type of io.Reader: %T", r)
}
Expand Down
8 changes: 8 additions & 0 deletions objstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,3 +595,11 @@ func (b *mockBucket) GetRange(ctx context.Context, name string, off, length int6
}
return nil, errors.New("GetRange has not been mocked")
}

func Test_TryToGetSizeLimitedReader(t *testing.T) {
b := &bytes.Buffer{}
r := io.LimitReader(b, 1024)
size, err := TryToGetSize(r)
testutil.Ok(t, err)
testutil.Equals(t, int64(1024), size)
}

0 comments on commit 27782a0

Please sign in to comment.