mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-05-03 06:22:56 +03:00
Pull request: home: imp err handling, marshalling
Merge in DNS/adguard-home from imp-code to master Squashed commit of the following: commit 9433fb9b0154a1cfaf804edbfa8531efbbcbf68a Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Fri May 14 19:24:32 2021 +0300 home: imp err handling, marshalling
This commit is contained in:
parent
9d788a2983
commit
a031cae447
6 changed files with 56 additions and 63 deletions
internal/home
|
@ -1,6 +1,7 @@
|
|||
package home
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
|
@ -115,17 +116,16 @@ func upgradeConfigSchema(oldVersion int, diskConf yobj) (err error) {
|
|||
|
||||
// The first schema upgrade:
|
||||
// No more "dnsfilter.txt", filters are now kept in data/filters/
|
||||
func upgradeSchema0to1(diskConf yobj) error {
|
||||
func upgradeSchema0to1(diskConf yobj) (err error) {
|
||||
log.Printf("%s(): called", funcName())
|
||||
|
||||
dnsFilterPath := filepath.Join(Context.workDir, "dnsfilter.txt")
|
||||
if _, err := os.Stat(dnsFilterPath); !os.IsNotExist(err) {
|
||||
log.Printf("Deleting %s as we don't need it anymore", dnsFilterPath)
|
||||
err = os.Remove(dnsFilterPath)
|
||||
if err != nil {
|
||||
log.Printf("Cannot remove %s due to %s", dnsFilterPath, err)
|
||||
// not fatal, move on
|
||||
}
|
||||
log.Printf("deleting %s as we don't need it anymore", dnsFilterPath)
|
||||
err = os.Remove(dnsFilterPath)
|
||||
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
log.Info("warning: %s", err)
|
||||
|
||||
// Go on.
|
||||
}
|
||||
|
||||
diskConf["schema_version"] = 1
|
||||
|
@ -136,17 +136,16 @@ func upgradeSchema0to1(diskConf yobj) error {
|
|||
// Second schema upgrade:
|
||||
// coredns is now dns in config
|
||||
// delete 'Corefile', since we don't use that anymore
|
||||
func upgradeSchema1to2(diskConf yobj) error {
|
||||
func upgradeSchema1to2(diskConf yobj) (err error) {
|
||||
log.Printf("%s(): called", funcName())
|
||||
|
||||
coreFilePath := filepath.Join(Context.workDir, "Corefile")
|
||||
if _, err := os.Stat(coreFilePath); !os.IsNotExist(err) {
|
||||
log.Printf("Deleting %s as we don't need it anymore", coreFilePath)
|
||||
err = os.Remove(coreFilePath)
|
||||
if err != nil {
|
||||
log.Printf("Cannot remove %s due to %s", coreFilePath, err)
|
||||
// not fatal, move on
|
||||
}
|
||||
log.Printf("deleting %s as we don't need it anymore", coreFilePath)
|
||||
err = os.Remove(coreFilePath)
|
||||
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
log.Info("warning: %s", err)
|
||||
|
||||
// Go on.
|
||||
}
|
||||
|
||||
if _, ok := diskConf["dns"]; !ok {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue