mirror of
https://github.com/rclone/rclone
synced 2024-12-23 14:23:44 +01:00
acd, onedrive: fix initialization order for token renewer - fixes #1442
This commit is contained in:
parent
d7811f72ad
commit
70b5b2f5c6
@ -192,6 +192,12 @@ func NewFs(name, root string) (fs.Fs, error) {
|
|||||||
}
|
}
|
||||||
f.features = (&fs.Features{CaseInsensitive: true, ReadMimeType: true}).Fill(f)
|
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
|
// Update endpoints
|
||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
err = f.pacer.Call(func() (bool, error) {
|
err = f.pacer.Call(func() (bool, error) {
|
||||||
@ -209,12 +215,6 @@ func NewFs(name, root string) (fs.Fs, error) {
|
|||||||
}
|
}
|
||||||
f.trueRootID = *rootInfo.Id
|
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)
|
f.dirCache = dircache.New(root, f.trueRootID, f)
|
||||||
|
|
||||||
// Find the current root
|
// Find the current root
|
||||||
|
@ -208,18 +208,18 @@ func NewFs(name, root string) (fs.Fs, error) {
|
|||||||
f.features = (&fs.Features{CaseInsensitive: true, ReadMimeType: true}).Fill(f)
|
f.features = (&fs.Features{CaseInsensitive: true, ReadMimeType: true}).Fill(f)
|
||||||
f.srv.SetErrorHandler(errorHandler)
|
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
|
// Renew the token in the background
|
||||||
f.tokenRenewer = oauthutil.NewRenew(f.String(), ts, func() error {
|
f.tokenRenewer = oauthutil.NewRenew(f.String(), ts, func() error {
|
||||||
_, _, err := f.readMetaDataForPath("")
|
_, _, err := f.readMetaDataForPath("")
|
||||||
return err
|
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)
|
f.dirCache = dircache.New(root, rootInfo.ID, f)
|
||||||
|
|
||||||
// Find the current root
|
// Find the current root
|
||||||
|
Loading…
Reference in New Issue
Block a user