File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
database/plugin/metadata/sqlite Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ type MetadataStoreSqlite struct {
4141 timerVacuum * time.Timer
4242 timerMutex sync.Mutex
4343 dataDir string
44+ closed bool
4445}
4546
4647// New creates a new database
@@ -134,7 +135,10 @@ func (d *MetadataStoreSqlite) init() error {
134135}
135136
136137func (d * MetadataStoreSqlite ) runVacuum () error {
137- if d .dataDir == "" {
138+ d .timerMutex .Lock ()
139+ closed := d .closed
140+ d .timerMutex .Unlock ()
141+ if d .dataDir == "" || closed {
138142 return nil
139143 }
140144 if result := d .DB ().Raw ("VACUUM" ); result .Error != nil {
@@ -147,6 +151,9 @@ func (d *MetadataStoreSqlite) runVacuum() error {
147151func (d * MetadataStoreSqlite ) scheduleDailyVacuum () {
148152 d .timerMutex .Lock ()
149153 defer d .timerMutex .Unlock ()
154+ if d .closed {
155+ return
156+ }
150157
151158 if d .timerVacuum != nil {
152159 d .timerVacuum .Stop ()
@@ -176,6 +183,7 @@ func (d *MetadataStoreSqlite) AutoMigrate(dst ...any) error {
176183// Close gets the database handle from our MetadataStore and closes it
177184func (d * MetadataStoreSqlite ) Close () error {
178185 d .timerMutex .Lock ()
186+ d .closed = true
179187 if d .timerVacuum != nil {
180188 d .timerVacuum .Stop ()
181189 d .timerVacuum = nil
You can’t perform that action at this time.
0 commit comments