Remove github.com/pkg/errors and replace with std library version
This is possible now that we no longer support go1.12 and brings rclone into line with standard practices in the Go world. This also removes errors.New and errors.Errorf from lib/errors and prefers the stdlib errors package over lib/errors.
This commit is contained in:
@@ -8,6 +8,7 @@ package qingstor
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -17,7 +18,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/rclone/rclone/fs/config"
|
||||
"github.com/rclone/rclone/fs/config/configmap"
|
||||
@@ -285,7 +285,7 @@ func qsServiceConnection(ctx context.Context, opt *Options) (*qs.Service, error)
|
||||
|
||||
func checkUploadChunkSize(cs fs.SizeSuffix) error {
|
||||
if cs < minChunkSize {
|
||||
return errors.Errorf("%s is less than %s", cs, minChunkSize)
|
||||
return fmt.Errorf("%s is less than %s", cs, minChunkSize)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -300,7 +300,7 @@ func (f *Fs) setUploadChunkSize(cs fs.SizeSuffix) (old fs.SizeSuffix, err error)
|
||||
|
||||
func checkUploadCutoff(cs fs.SizeSuffix) error {
|
||||
if cs > maxUploadCutoff {
|
||||
return errors.Errorf("%s is greater than %s", cs, maxUploadCutoff)
|
||||
return fmt.Errorf("%s is greater than %s", cs, maxUploadCutoff)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -329,11 +329,11 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
|
||||
}
|
||||
err = checkUploadChunkSize(opt.ChunkSize)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "qingstor: chunk size")
|
||||
return nil, fmt.Errorf("qingstor: chunk size: %w", err)
|
||||
}
|
||||
err = checkUploadCutoff(opt.UploadCutoff)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "qingstor: upload cutoff")
|
||||
return nil, fmt.Errorf("qingstor: upload cutoff: %w", err)
|
||||
}
|
||||
svc, err := qsServiceConnection(ctx, opt)
|
||||
if err != nil {
|
||||
@@ -884,7 +884,7 @@ func (f *Fs) cleanUpBucket(ctx context.Context, bucket string) (err error) {
|
||||
var resp *qs.ListMultipartUploadsOutput
|
||||
resp, err = bucketInit.ListMultipartUploads(&req)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "clean up bucket list multipart uploads")
|
||||
return fmt.Errorf("clean up bucket list multipart uploads: %w", err)
|
||||
}
|
||||
for _, upload := range resp.Uploads {
|
||||
if upload.Created != nil && upload.Key != nil && upload.UploadID != nil {
|
||||
@@ -896,7 +896,7 @@ func (f *Fs) cleanUpBucket(ctx context.Context, bucket string) (err error) {
|
||||
}
|
||||
_, abortErr := bucketInit.AbortMultipartUpload(*upload.Key, &req)
|
||||
if abortErr != nil {
|
||||
err = errors.Wrapf(abortErr, "failed to remove multipart upload for %q", *upload.Key)
|
||||
err = fmt.Errorf("failed to remove multipart upload for %q: %w", *upload.Key, abortErr)
|
||||
fs.Errorf(f, "%v", err)
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -8,13 +8,13 @@ package qingstor
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"errors"
|
||||
"fmt"
|
||||
"hash"
|
||||
"io"
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/rclone/rclone/lib/atexit"
|
||||
qs "github.com/yunify/qingstor-sdk-go/v3/service"
|
||||
@@ -175,7 +175,7 @@ func (u *uploader) upload() error {
|
||||
u.init()
|
||||
|
||||
if u.cfg.partSize < minMultiPartSize {
|
||||
return errors.Errorf("part size must be at least %d bytes", minMultiPartSize)
|
||||
return fmt.Errorf("part size must be at least %d bytes", minMultiPartSize)
|
||||
}
|
||||
|
||||
// Do one read to determine if we have more than one part
|
||||
@@ -184,7 +184,7 @@ func (u *uploader) upload() error {
|
||||
fs.Debugf(u, "Uploading as single part object to QingStor")
|
||||
return u.singlePartUpload(reader, u.readerPos)
|
||||
} else if err != nil {
|
||||
return errors.Errorf("read upload data failed: %s", err)
|
||||
return fmt.Errorf("read upload data failed: %s", err)
|
||||
}
|
||||
|
||||
fs.Debugf(u, "Uploading as multi-part object to QingStor")
|
||||
|
||||
Reference in New Issue
Block a user