mirror of
https://github.com/rclone/rclone.git
synced 2024-11-24 23:04:16 +08:00
hasher: fix error from trying to stop an already-stopped db
Before this change, Hasher would sometimes try to stop a bolt db that was already stopped, resulting in an error. This change fixes the issue by checking first whether the db is already stopped. https://forum.rclone.org/t/hasher-with-gdrive-backend-does-not-return-sha1-sha256-for-old-files/44680/11?u=nielash
This commit is contained in:
parent
ac830ddd42
commit
ff0acfb568
|
@ -439,7 +439,7 @@ func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string
|
|||
|
||||
// Shutdown the backend, closing any background tasks and any cached connections.
|
||||
func (f *Fs) Shutdown(ctx context.Context) (err error) {
|
||||
if f.db != nil {
|
||||
if f.db != nil && !f.db.IsStopped() {
|
||||
err = f.db.Stop(false)
|
||||
}
|
||||
if do := f.Fs.Features().Shutdown; do != nil {
|
||||
|
|
|
@ -293,6 +293,11 @@ func (db *DB) Stop(remove bool) error {
|
|||
return db.Do(false, &opStop{remove: remove})
|
||||
}
|
||||
|
||||
// IsStopped returns true if db is already stopped
|
||||
func (db *DB) IsStopped() bool {
|
||||
return len(dbMap) == 0
|
||||
}
|
||||
|
||||
// opStop: close database and stop operation loop
|
||||
type opStop struct {
|
||||
remove bool
|
||||
|
|
|
@ -36,5 +36,10 @@ func (*DB) Stop(remove bool) error {
|
|||
return ErrUnsupported
|
||||
}
|
||||
|
||||
// IsStopped returns true if db is already stopped
|
||||
func (db *DB) IsStopped() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Exit stops all databases
|
||||
func Exit() {}
|
||||
|
|
Loading…
Reference in New Issue
Block a user