mirror of
https://github.com/rancher/steve.git
synced 2025-09-11 20:29:52 +00:00
* On Reset, remove all the sqlite files, not just the main one. * Avoid resetting the database and cache when not needed. Avoid resetting when a change doesn't bring in new schema fields. Always reset when a CRD is deleted. * Force a database reset when a new CRD is added. * Improve code readability. No functional change.
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"errors"
|
||||
|
||||
"github.com/rancher/steve/pkg/sqlcache/db/transaction"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
// needed for drivers
|
||||
_ "modernc.org/sqlite"
|
||||
@@ -416,9 +417,12 @@ func (c *client) NewConnection(useTempDir bool) (string, error) {
|
||||
}
|
||||
}
|
||||
if !useTempDir {
|
||||
err := os.RemoveAll(InformerObjectCacheDBPath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
for _, suffix := range []string{"", "-shm", "-wal"} {
|
||||
f := InformerObjectCacheDBPath + suffix
|
||||
err := os.RemoveAll(f)
|
||||
if err != nil {
|
||||
logrus.Errorf("error removing existing db file %s: %v", f, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user