Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

onedrive: fix error handling broken by removal of github.com/pkg/errors

Nick Craig-Wood21ba4d9a182c
diff --git a/backend/onedrive/onedrive.go b/backend/onedrive/onedrive.go
index d76e17a35..b49dcbf33 100644
--- a/backend/onedrive/onedrive.go
+++ b/backend/onedrive/onedrive.go
@@ -827,9 +827,12 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
// Get rootID
rootInfo, _, err := f.readMetaDataForPath(ctx, "")
- if err != nil || rootInfo.GetID() == "" {
+ if err != nil {
return nil, fmt.Errorf("failed to get root: %w", err)
}
+ if rootInfo.GetID() == "" {
+ return nil, errors.New("failed to get root: ID was empty")
+ }
f.dirCache = dircache.New(root, rootInfo.GetID(), f)
@@ -1188,7 +1191,10 @@ func (f *Fs) waitForJob(ctx context.Context, location string, o *Object) error {
return fmt.Errorf("%s: async operation returned %q", o.remote, status.Status)
case "completed":
err = o.readMetaData(ctx)
- return fmt.Errorf("async operation completed but readMetaData failed: %w", err)
+ if err != nil {
+ return fmt.Errorf("async operation completed but readMetaData failed: %w", err)
+ }
+ return nil
}
time.Sleep(1 * time.Second)