From 3f159bac16301e69d32ec3a64474c0960af9f862 Mon Sep 17 00:00:00 2001 From: rkonfj Date: Fri, 8 Dec 2023 12:33:51 +0800 Subject: [PATCH] backend: fs implements the `Shutdowner` interface Since `tokenRenewer` adds a Shutdown method, we should call it to clean up resources. changes backends: onedrive,box,pcloud,amazonclouddrive,hidrive,jottacloud,sharefile ,premiumizeme Signed-off-by: rkonfj --- backend/amazonclouddrive/amazonclouddrive.go | 7 +++++++ backend/box/box.go | 7 +++++++ backend/hidrive/hidrive.go | 7 +++++++ backend/jottacloud/jottacloud.go | 7 +++++++ backend/onedrive/onedrive.go | 7 +++++++ backend/pcloud/pcloud.go | 7 +++++++ backend/premiumizeme/premiumizeme.go | 7 +++++++ backend/sharefile/sharefile.go | 7 +++++++ 8 files changed, 56 insertions(+) diff --git a/backend/amazonclouddrive/amazonclouddrive.go b/backend/amazonclouddrive/amazonclouddrive.go index 1bc6bcb84..c5a123915 100644 --- a/backend/amazonclouddrive/amazonclouddrive.go +++ b/backend/amazonclouddrive/amazonclouddrive.go @@ -1346,6 +1346,12 @@ func (f *Fs) changeNotifyRunner(notifyFunc func(string, fs.EntryType), checkpoin return checkpoint } +// Shutdown shutdown the fs +func (f *Fs) Shutdown(ctx context.Context) error { + f.tokenRenewer.Shutdown() + return nil +} + // ID returns the ID of the Object if known, or "" if not func (o *Object) ID() string { if o.info.Id == nil { @@ -1363,6 +1369,7 @@ var ( _ fs.DirMover = (*Fs)(nil) _ fs.DirCacheFlusher = (*Fs)(nil) _ fs.ChangeNotifier = (*Fs)(nil) + _ fs.Shutdowner = (*Fs)(nil) _ fs.Object = (*Object)(nil) _ fs.MimeTyper = &Object{} _ fs.IDer = &Object{} diff --git a/backend/box/box.go b/backend/box/box.go index 26e2cb356..4f38955eb 100644 --- a/backend/box/box.go +++ b/backend/box/box.go @@ -1207,6 +1207,12 @@ func (f *Fs) CleanUp(ctx context.Context) (err error) { return err } +// Shutdown shutdown the fs +func (f *Fs) Shutdown(ctx context.Context) error { + f.tokenRenewer.Shutdown() + return nil +} + // ChangeNotify calls the passed function with a path that has had changes. // If the implementation uses polling, it should adhere to the given interval. // @@ -1719,6 +1725,7 @@ var ( _ fs.DirCacheFlusher = (*Fs)(nil) _ fs.PublicLinker = (*Fs)(nil) _ fs.CleanUpper = (*Fs)(nil) + _ fs.Shutdowner = (*Fs)(nil) _ fs.Object = (*Object)(nil) _ fs.IDer = (*Object)(nil) ) diff --git a/backend/hidrive/hidrive.go b/backend/hidrive/hidrive.go index 500e6f7cf..6f690f629 100644 --- a/backend/hidrive/hidrive.go +++ b/backend/hidrive/hidrive.go @@ -762,6 +762,12 @@ func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string return nil } +// Shutdown shutdown the fs +func (f *Fs) Shutdown(ctx context.Context) error { + f.tokenRenewer.Shutdown() + return nil +} + // ------------------------------------------------------------ // Fs returns the parent Fs. @@ -997,6 +1003,7 @@ var ( _ fs.Copier = (*Fs)(nil) _ fs.Mover = (*Fs)(nil) _ fs.DirMover = (*Fs)(nil) + _ fs.Shutdowner = (*Fs)(nil) _ fs.Object = (*Object)(nil) _ fs.IDer = (*Object)(nil) ) diff --git a/backend/jottacloud/jottacloud.go b/backend/jottacloud/jottacloud.go index e9176f5b0..6fb68b289 100644 --- a/backend/jottacloud/jottacloud.go +++ b/backend/jottacloud/jottacloud.go @@ -1680,6 +1680,12 @@ func (f *Fs) CleanUp(ctx context.Context) error { return nil } +// Shutdown shutdown the fs +func (f *Fs) Shutdown(ctx context.Context) error { + f.tokenRenewer.Shutdown() + return nil +} + // Hashes returns the supported hash sets. func (f *Fs) Hashes() hash.Set { return hash.Set(hash.MD5) @@ -2104,6 +2110,7 @@ var ( _ fs.Abouter = (*Fs)(nil) _ fs.UserInfoer = (*Fs)(nil) _ fs.CleanUpper = (*Fs)(nil) + _ fs.Shutdowner = (*Fs)(nil) _ fs.Object = (*Object)(nil) _ fs.MimeTyper = (*Object)(nil) _ fs.Metadataer = (*Object)(nil) diff --git a/backend/onedrive/onedrive.go b/backend/onedrive/onedrive.go index 00781db8d..5d8c68d03 100644 --- a/backend/onedrive/onedrive.go +++ b/backend/onedrive/onedrive.go @@ -1377,6 +1377,12 @@ func (f *Fs) ListR(ctx context.Context, dir string, callback fs.ListRCallback) ( } +// Shutdown shutdown the fs +func (f *Fs) Shutdown(ctx context.Context) error { + f.tokenRenewer.Shutdown() + return nil +} + // Creates from the parameters passed in a half finished Object which // must have setMetaData called on it // @@ -2755,6 +2761,7 @@ var ( _ fs.PublicLinker = (*Fs)(nil) _ fs.CleanUpper = (*Fs)(nil) _ fs.ListRer = (*Fs)(nil) + _ fs.Shutdowner = (*Fs)(nil) _ fs.Object = (*Object)(nil) _ fs.MimeTyper = &Object{} _ fs.IDer = &Object{} diff --git a/backend/pcloud/pcloud.go b/backend/pcloud/pcloud.go index 9d6256b1a..64a48c25c 100644 --- a/backend/pcloud/pcloud.go +++ b/backend/pcloud/pcloud.go @@ -948,6 +948,12 @@ func (f *Fs) About(ctx context.Context) (usage *fs.Usage, err error) { return usage, nil } +// Shutdown shutdown the fs +func (f *Fs) Shutdown(ctx context.Context) error { + f.tokenRenewer.Shutdown() + return nil +} + // Hashes returns the supported hash sets. func (f *Fs) Hashes() hash.Set { // EU region supports SHA1 and SHA256 (but rclone doesn't @@ -1280,6 +1286,7 @@ var ( _ fs.DirCacheFlusher = (*Fs)(nil) _ fs.PublicLinker = (*Fs)(nil) _ fs.Abouter = (*Fs)(nil) + _ fs.Shutdowner = (*Fs)(nil) _ fs.Object = (*Object)(nil) _ fs.IDer = (*Object)(nil) ) diff --git a/backend/premiumizeme/premiumizeme.go b/backend/premiumizeme/premiumizeme.go index 4adaa5af2..ef54aac9f 100644 --- a/backend/premiumizeme/premiumizeme.go +++ b/backend/premiumizeme/premiumizeme.go @@ -770,6 +770,12 @@ func (f *Fs) PublicLink(ctx context.Context, remote string, expire fs.Duration, return o.(*Object).url, nil } +// Shutdown shutdown the fs +func (f *Fs) Shutdown(ctx context.Context) error { + f.tokenRenewer.Shutdown() + return nil +} + // About gets quota information func (f *Fs) About(ctx context.Context) (usage *fs.Usage, err error) { var resp *http.Response @@ -1110,6 +1116,7 @@ var ( _ fs.DirCacheFlusher = (*Fs)(nil) _ fs.Abouter = (*Fs)(nil) _ fs.PublicLinker = (*Fs)(nil) + _ fs.Shutdowner = (*Fs)(nil) _ fs.Object = (*Object)(nil) _ fs.MimeTyper = (*Object)(nil) _ fs.IDer = (*Object)(nil) diff --git a/backend/sharefile/sharefile.go b/backend/sharefile/sharefile.go index 92e618010..a135f8705 100644 --- a/backend/sharefile/sharefile.go +++ b/backend/sharefile/sharefile.go @@ -1176,6 +1176,12 @@ func (f *Fs) DirCacheFlush() { f.dirCache.ResetRoot() } +// Shutdown shutdown the fs +func (f *Fs) Shutdown(ctx context.Context) error { + f.tokenRenewer.Shutdown() + return nil +} + // Hashes returns the supported hash sets. func (f *Fs) Hashes() hash.Set { return hash.Set(hash.MD5) @@ -1466,6 +1472,7 @@ var ( _ fs.Copier = (*Fs)(nil) // _ fs.PutStreamer = (*Fs)(nil) _ fs.DirCacheFlusher = (*Fs)(nil) + _ fs.Shutdowner = (*Fs)(nil) _ fs.Object = (*Object)(nil) _ fs.IDer = (*Object)(nil) )