mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-12-23 23:28:17 +03:00
ee619b2dbd
Squashed commit of the following: commit a1bd3c249be043108c84a902d2e88bf80946d444 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 4 14:59:37 2024 +0300 all: upd more commit 9e55bbb02c2af2064aa2a2ca7b49fd28b544a02c Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Apr 4 14:12:45 2024 +0300 all: upd go code
54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
package configmigrate
|
|
|
|
import "github.com/AdguardTeam/golibs/errors"
|
|
|
|
// migrateTo15 performs the following changes:
|
|
//
|
|
// # BEFORE:
|
|
// 'schema_version': 14
|
|
// 'dns':
|
|
// # …
|
|
// 'querylog_enabled': true
|
|
// 'querylog_file_enabled': true
|
|
// 'querylog_interval': '2160h'
|
|
// 'querylog_size_memory': 1000
|
|
// 'querylog':
|
|
// # …
|
|
// # …
|
|
//
|
|
// # AFTER:
|
|
// 'schema_version': 15
|
|
// 'dns':
|
|
// # …
|
|
// 'querylog':
|
|
// 'enabled': true
|
|
// 'file_enabled': true
|
|
// 'interval': '2160h'
|
|
// 'size_memory': 1000
|
|
// 'ignored': []
|
|
// # …
|
|
// # …
|
|
func migrateTo15(diskConf yobj) (err error) {
|
|
diskConf["schema_version"] = 15
|
|
|
|
dns, ok, err := fieldVal[yobj](diskConf, "dns")
|
|
if !ok {
|
|
return err
|
|
}
|
|
|
|
qlog := map[string]any{
|
|
"ignored": yarr{},
|
|
"enabled": true,
|
|
"file_enabled": true,
|
|
"interval": "2160h",
|
|
"size_memory": 1000,
|
|
}
|
|
diskConf["querylog"] = qlog
|
|
|
|
return errors.Join(
|
|
moveVal[bool](dns, qlog, "querylog_enabled", "enabled"),
|
|
moveVal[bool](dns, qlog, "querylog_file_enabled", "file_enabled"),
|
|
moveVal[any](dns, qlog, "querylog_interval", "interval"),
|
|
moveVal[int](dns, qlog, "querylog_size_memory", "size_memory"),
|
|
)
|
|
}
|