Remove unnecessary type conversions.

This commit is contained in:
Martin Smith
2025-02-28 19:38:33 +00:00
parent 2099ec1cd6
commit 092899df8b
17 changed files with 30 additions and 30 deletions

View File

@@ -338,7 +338,7 @@ func (be *Backend) List(ctx context.Context, t backend.FileType, fn func(backend
fi := backend.FileInfo{
Name: path.Base(m),
Size: int64(attrs.Size),
Size: attrs.Size,
}
err = fn(fi)

View File

@@ -36,7 +36,7 @@ func TestLimiterWrapping(t *testing.T) {
func TestReadLimiter(t *testing.T) {
reader := bytes.NewReader(make([]byte, 300))
limiter := rate.NewLimiter(rate.Limit(10000), int(100))
limiter := rate.NewLimiter(rate.Limit(10000), 100)
limReader := rateLimitedReader{reader, limiter}
n, err := limReader.Read([]byte{})
@@ -54,7 +54,7 @@ func TestReadLimiter(t *testing.T) {
func TestWriteLimiter(t *testing.T) {
writer := &bytes.Buffer{}
limiter := rate.NewLimiter(rate.Limit(10000), int(100))
limiter := rate.NewLimiter(rate.Limit(10000), 100)
limReader := rateLimitedWriter{writer, limiter}
n, err := limReader.Write([]byte{})

View File

@@ -302,7 +302,7 @@ func (be *Backend) Save(ctx context.Context, h backend.Handle, rd backend.Rewind
opts.StorageClass = be.cfg.StorageClass
}
info, err := be.client.PutObject(ctx, be.cfg.Bucket, objName, io.NopCloser(rd), int64(rd.Length()), opts)
info, err := be.client.PutObject(ctx, be.cfg.Bucket, objName, io.NopCloser(rd), rd.Length(), opts)
// sanity check
if err == nil && info.Size != rd.Length() {

View File

@@ -101,7 +101,7 @@ func countingBlocker() (func(), func(int) int) {
}
func concurrencyTester(t *testing.T, setup func(m *mock.Backend), handler func(be backend.Backend) func() error, unblock func(int) int, isUnlimited bool) {
expectBlocked := int(2)
expectBlocked := 2
workerCount := expectBlocked + 1
m := mock.NewBackend()

View File

@@ -696,7 +696,7 @@ var testStrings = []struct {
func store(t testing.TB, b backend.Backend, tpe backend.FileType, data []byte) backend.Handle {
id := restic.Hash(data)
h := backend.Handle{Name: id.String(), Type: tpe}
err := b.Save(context.TODO(), h, backend.NewByteReader([]byte(data), b.Hasher()))
err := b.Save(context.TODO(), h, backend.NewByteReader(data, b.Hasher()))
test.OK(t, err)
return h
}

View File

@@ -32,7 +32,7 @@ func TestDefaultLoad(t *testing.T) {
// happy case, assert correct parameters are passed around and content stream is closed
err := util.DefaultLoad(context.TODO(), h, 10, 11, func(ctx context.Context, ih backend.Handle, length int, offset int64) (io.ReadCloser, error) {
rtest.Equals(t, h, ih)
rtest.Equals(t, int(10), length)
rtest.Equals(t, 10, length)
rtest.Equals(t, int64(11), offset)
return rd, nil