build: modernize with "go fix -minmax": use min and max builtins
This commit is contained in:
@@ -1897,10 +1897,8 @@ func (o *Object) uploadResume(ctx context.Context, in io.Reader, leaf, directory
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now upload the content in chunks
|
// Now upload the content in chunks
|
||||||
chunkSize := int64(o.fs.opt.ChunkSize)
|
// Note 256k is the minimum chunk size according to Huawei Drive API
|
||||||
if chunkSize < 256*1024 {
|
chunkSize := max(int64(o.fs.opt.ChunkSize), 256*1024)
|
||||||
chunkSize = 256 * 1024 // Minimum chunk size according to Huawei Drive API
|
|
||||||
}
|
|
||||||
if chunkSize > 64*1024*1024 {
|
if chunkSize > 64*1024*1024 {
|
||||||
chunkSize = 64 * 1024 * 1024 // Maximum single upload size
|
chunkSize = 64 * 1024 * 1024 // Maximum single upload size
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -736,10 +736,7 @@ func (f *PhotosFs) ListR(ctx context.Context, dir string, callback fs.ListRCallb
|
|||||||
}
|
}
|
||||||
close(jobCh)
|
close(jobCh)
|
||||||
|
|
||||||
workers := fs.GetConfig(ctx).Checkers
|
workers := min(len(jobs), fs.GetConfig(ctx).Checkers)
|
||||||
if len(jobs) < workers {
|
|
||||||
workers = len(jobs)
|
|
||||||
}
|
|
||||||
errs := make(chan error, workers)
|
errs := make(chan error, workers)
|
||||||
|
|
||||||
for range workers {
|
for range workers {
|
||||||
|
|||||||
+8
-14
@@ -125,13 +125,10 @@ func (o *RangeOption) Decode(size int64) (offset, limit int64) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if o.End >= 0 {
|
if o.End >= 0 {
|
||||||
offset = size - o.End
|
// RFC 7233 section 2.1: if the suffix-length is
|
||||||
if offset < 0 {
|
// larger than the representation, use the entire
|
||||||
// RFC 7233 section 2.1: if the suffix-length is
|
// representation.
|
||||||
// larger than the representation, use the entire
|
offset = max(size-o.End, 0)
|
||||||
// representation.
|
|
||||||
offset = 0
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
offset = 0
|
offset = 0
|
||||||
}
|
}
|
||||||
@@ -168,13 +165,10 @@ func FixRangeOption(options []OpenOption, size int64) {
|
|||||||
case *RangeOption:
|
case *RangeOption:
|
||||||
// If start is < 0 then fetch from the end
|
// If start is < 0 then fetch from the end
|
||||||
if x.Start < 0 {
|
if x.Start < 0 {
|
||||||
start := size - x.End
|
// RFC 7233 section 2.1: if the suffix-length is
|
||||||
if start < 0 {
|
// larger than the representation, use the entire
|
||||||
// RFC 7233 section 2.1: if the suffix-length is
|
// representation (#6310).
|
||||||
// larger than the representation, use the entire
|
start := max(size-x.End, 0)
|
||||||
// representation (#6310).
|
|
||||||
start = 0
|
|
||||||
}
|
|
||||||
x = &RangeOption{Start: start, End: -1}
|
x = &RangeOption{Start: start, End: -1}
|
||||||
options[i] = x
|
options[i] = x
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-4
@@ -126,10 +126,7 @@ func CheckContentRange(resp *http.Response, options []fs.OpenOption, size int64)
|
|||||||
expectedEnd = rangeSize - 1
|
expectedEnd = rangeSize - 1
|
||||||
}
|
}
|
||||||
} else if rangeSize >= 0 {
|
} else if rangeSize >= 0 {
|
||||||
expectedStart = rangeSize - requested.End
|
expectedStart = max(rangeSize-requested.End, 0)
|
||||||
if expectedStart < 0 {
|
|
||||||
expectedStart = 0
|
|
||||||
}
|
|
||||||
expectedEnd = rangeSize - 1
|
expectedEnd = rangeSize - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user