diff --git a/internal/caches/list_file_db.go b/internal/caches/list_file_db.go index dd5a04d..86038ab 100644 --- a/internal/caches/list_file_db.go +++ b/internal/caches/list_file_db.go @@ -432,6 +432,10 @@ func (this *FileListDB) Close() error { _ = this.listOlderItemsStmt.Close() } + if this.writeBatch != nil { + this.writeBatch.Close() + } + var errStrings []string if this.readDB != nil { @@ -448,10 +452,6 @@ func (this *FileListDB) Close() error { } } - if this.writeBatch != nil { - this.writeBatch.Close() - } - if len(errStrings) == 0 { return nil } diff --git a/internal/utils/dbs/batch.go b/internal/utils/dbs/batch.go index b35c9ef..9cecabd 100644 --- a/internal/utils/dbs/batch.go +++ b/internal/utils/dbs/batch.go @@ -64,6 +64,11 @@ For: for { // closed if this.isClosed { + if lastTx != nil { + _ = lastTx.Commit() + lastTx = nil + } + return }