Maintain CleanupIntervalInSeconds for backwards-compatibility

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
This commit is contained in:
ItalyPaleAle 2023-02-04 00:43:58 +00:00
parent 958b1f37c0
commit 95aa6fcbf1
2 changed files with 17 additions and 1 deletions

View File

@ -204,7 +204,7 @@ func (a *sqliteDBAccess) getConnectionString() (string, error) {
// If the connection string doesn't begin with "file:", add the prefix
if !strings.HasPrefix(lc, "file:") {
a.logger.Info("prefix 'file:' added to the connection string")
a.logger.Debug("prefix 'file:' added to the connection string")
connString = "file:" + connString
}

View File

@ -43,6 +43,9 @@ type sqliteMetadataStruct struct {
BusyTimeoutStr string `json:"busyTimeout" mapstructure:"busyTimeout"` // Busy timeout as a time.Duration string
DisableWAL bool `json:"disableWAL" mapstructure:"disableWAL"` // Disable WAL journaling. You should not use WAL if the database is stored on a network filesystem (or data corruption may happen). This is ignored if the database is in-memory.
// Deprecated properties, maintained for backwards-compatibility
CleanupIntervalInSeconds string `json:"cleanupIntervalInSeconds" mapstructure:"cleanupIntervalInSeconds"`
timeout time.Duration
cleanupInterval time.Duration
busyTimeout time.Duration
@ -90,6 +93,16 @@ func (m *sqliteMetadataStruct) InitWithMetadata(meta state.Metadata) error {
if parsed > 0 {
m.cleanupInterval = parsed
}
} else if m.CleanupIntervalInSeconds != "" {
cleanupIntervalInSec, err := strconv.ParseInt(m.CleanupIntervalInSeconds, 10, 0)
if err != nil {
return fmt.Errorf("invalid value for 'cleanupIntervalInSeconds': %s", m.CleanupIntervalInSeconds)
}
// Non-positive value from meta means disable auto cleanup.
if cleanupIntervalInSec > 0 {
m.cleanupInterval = time.Duration(cleanupIntervalInSec) * time.Second
}
}
// Busy timeout
@ -115,6 +128,9 @@ func (m *sqliteMetadataStruct) reset() {
m.CleanupIntervalStr = ""
m.BusyTimeoutStr = ""
m.DisableWAL = false
m.CleanupIntervalInSeconds = ""
m.timeout = defaultTimeout
m.cleanupInterval = defaultCleanupInternal
m.busyTimeout = defaultBusyTimeout