diff --git a/amazonclouddrive/amazonclouddrive.go b/amazonclouddrive/amazonclouddrive.go index bf4f42a71..3b21b5a18 100644 --- a/amazonclouddrive/amazonclouddrive.go +++ b/amazonclouddrive/amazonclouddrive.go @@ -192,6 +192,12 @@ func NewFs(name, root string) (fs.Fs, error) { } f.features = (&fs.Features{CaseInsensitive: true, ReadMimeType: true}).Fill(f) + // Renew the token in the background + f.tokenRenewer = oauthutil.NewRenew(f.String(), ts, func() error { + _, err := f.getRootInfo() + return err + }) + // Update endpoints var resp *http.Response err = f.pacer.Call(func() (bool, error) { @@ -209,12 +215,6 @@ func NewFs(name, root string) (fs.Fs, error) { } f.trueRootID = *rootInfo.Id - // Renew the token in the background - f.tokenRenewer = oauthutil.NewRenew(f.String(), ts, func() error { - _, err := f.getRootInfo() - return err - }) - f.dirCache = dircache.New(root, f.trueRootID, f) // Find the current root diff --git a/onedrive/onedrive.go b/onedrive/onedrive.go index edf6da438..c0ae1ea24 100644 --- a/onedrive/onedrive.go +++ b/onedrive/onedrive.go @@ -208,18 +208,18 @@ func NewFs(name, root string) (fs.Fs, error) { f.features = (&fs.Features{CaseInsensitive: true, ReadMimeType: true}).Fill(f) f.srv.SetErrorHandler(errorHandler) - // Get rootID - rootInfo, _, err := f.readMetaDataForPath("") - if err != nil || rootInfo.ID == "" { - return nil, errors.Wrap(err, "failed to get root") - } - // Renew the token in the background f.tokenRenewer = oauthutil.NewRenew(f.String(), ts, func() error { _, _, err := f.readMetaDataForPath("") return err }) + // Get rootID + rootInfo, _, err := f.readMetaDataForPath("") + if err != nil || rootInfo.ID == "" { + return nil, errors.Wrap(err, "failed to get root") + } + f.dirCache = dircache.New(root, rootInfo.ID, f) // Find the current root