mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 09:54:44 +01: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.
|
// Shutdown the backend, closing any background tasks and any cached connections.
|
||||||
func (f *Fs) Shutdown(ctx context.Context) (err error) {
|
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)
|
err = f.db.Stop(false)
|
||||||
}
|
}
|
||||||
if do := f.Fs.Features().Shutdown; do != nil {
|
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})
|
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
|
// opStop: close database and stop operation loop
|
||||||
type opStop struct {
|
type opStop struct {
|
||||||
remove bool
|
remove bool
|
||||||
|
@ -36,5 +36,10 @@ func (*DB) Stop(remove bool) error {
|
|||||||
return ErrUnsupported
|
return ErrUnsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsStopped returns true if db is already stopped
|
||||||
|
func (db *DB) IsStopped() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// Exit stops all databases
|
// Exit stops all databases
|
||||||
func Exit() {}
|
func Exit() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user