build: modernize with "go fix -minmax": use min and max builtins

This commit is contained in:
Nick Craig-Wood
2026-08-21 12:23:31 +01:00
parent bfd0e3f3c2
commit b5bea683c5
4 changed files with 12 additions and 26 deletions
+2 -4
View File
@@ -1897,10 +1897,8 @@ func (o *Object) uploadResume(ctx context.Context, in io.Reader, leaf, directory
}
// Now upload the content in chunks
chunkSize := int64(o.fs.opt.ChunkSize)
if chunkSize < 256*1024 {
chunkSize = 256 * 1024 // Minimum chunk size according to Huawei Drive API
}
// Note 256k is the minimum chunk size according to Huawei Drive API
chunkSize := max(int64(o.fs.opt.ChunkSize), 256*1024)
if chunkSize > 64*1024*1024 {
chunkSize = 64 * 1024 * 1024 // Maximum single upload size
}
+1 -4
View File
@@ -736,10 +736,7 @@ func (f *PhotosFs) ListR(ctx context.Context, dir string, callback fs.ListRCallb
}
close(jobCh)
workers := fs.GetConfig(ctx).Checkers
if len(jobs) < workers {
workers = len(jobs)
}
workers := min(len(jobs), fs.GetConfig(ctx).Checkers)
errs := make(chan error, workers)
for range workers {
+8 -14
View File
@@ -125,13 +125,10 @@ func (o *RangeOption) Decode(size int64) (offset, limit int64) {
}
} else {
if o.End >= 0 {
offset = size - o.End
if offset < 0 {
// RFC 7233 section 2.1: if the suffix-length is
// larger than the representation, use the entire
// representation.
offset = 0
}
// RFC 7233 section 2.1: if the suffix-length is
// larger than the representation, use the entire
// representation.
offset = max(size-o.End, 0)
} else {
offset = 0
}
@@ -168,13 +165,10 @@ func FixRangeOption(options []OpenOption, size int64) {
case *RangeOption:
// If start is < 0 then fetch from the end
if x.Start < 0 {
start := size - x.End
if start < 0 {
// RFC 7233 section 2.1: if the suffix-length is
// larger than the representation, use the entire
// representation (#6310).
start = 0
}
// RFC 7233 section 2.1: if the suffix-length is
// larger than the representation, use the entire
// representation (#6310).
start := max(size-x.End, 0)
x = &RangeOption{Start: start, End: -1}
options[i] = x
}
+1 -4
View File
@@ -126,10 +126,7 @@ func CheckContentRange(resp *http.Response, options []fs.OpenOption, size int64)
expectedEnd = rangeSize - 1
}
} else if rangeSize >= 0 {
expectedStart = rangeSize - requested.End
if expectedStart < 0 {
expectedStart = 0
}
expectedStart = max(rangeSize-requested.End, 0)
expectedEnd = rangeSize - 1
}