From 21ba4d9a182c0097c2a12e52f877eb663a136ef1 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 9 Nov 2021 13:00:51 +0000 Subject: [PATCH] onedrive: fix error handling broken by removal of github.com/pkg/errors There were instances of errors.Wrap being called with a nil error which the conversion didn't deal with correctly. --- backend/onedrive/onedrive.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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)