From c3bbcc15e73ce926d29d8b343dc4846b1eb187e8 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Wed, 7 Sep 2022 14:54:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/caches/list_file_db.go | 8 ++++---- internal/utils/dbs/batch.go | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) 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 }