Pull request 2470: 7964-fix-log-severity

Updates #7964.

Squashed commit of the following:

commit bd48a1052a441a19a50f8079dd50d6c3ba224fcf
Merge: c183b9c3b 0e6a55efa
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Mon Sep 8 18:07:07 2025 +0300

    Merge branch 'master' into 7964-fix-log-severity

commit c183b9c3b5
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Thu Sep 4 14:29:00 2025 +0300

    filtering: imp code

commit f728b8d059
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Thu Sep 4 14:13:07 2025 +0300

    all: fix log severity
This commit is contained in:
Stanislav Chzhen 2025-09-08 18:25:04 +03:00
parent 0e6a55efa0
commit e5c4e24e16
2 changed files with 21 additions and 10 deletions

View File

@ -30,10 +30,12 @@ NOTE: Add new changes BELOW THIS COMMENT.
### Fixed
- Lowered the severity of log messages for failed deletion of old filter files ([#7964]).
- Authentication errors in the Web UI when AdGuard Home is behind a proxy that sets Basic Auth headers ([#7987]).
- The HTTP API `GET /control/profile` endpoint failing when no users were configured ([#7985]).
- Missing warning on the *Encryption Settings* page when using a certificate without an IP address.
[#7964]: https://github.com/AdguardTeam/AdGuardHome/issues/7964
[#7979]: https://github.com/AdguardTeam/AdGuardHome/issues/7979
[#7985]: https://github.com/AdguardTeam/AdGuardHome/issues/7985
[#7987]: https://github.com/AdguardTeam/AdGuardHome/issues/7987

View File

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"log/slog"
"net/http"
"net/netip"
"os"
@ -448,22 +449,30 @@ func (d *DNSFilter) refreshFiltersIntl(block, allow, force bool) (int, bool) {
d.EnableFilters(false)
for i := range lists {
uf := &lists[i]
updated := toUpd[i]
if !updated {
continue
}
p := uf.Path(d.conf.DataDir)
err := os.Remove(p + ".old")
if err != nil {
d.logger.ErrorContext(ctx, "removing old filter", "path", p, slogutil.KeyError, err)
if toUpd[i] {
removeOldFilterFile(ctx, d.logger, lists[i].Path(d.conf.DataDir))
}
}
return updNum, false
}
// removeOldFilterFile deletes the old filter file and logs any error at the
// appropriate level. l must not be nil.
func removeOldFilterFile(ctx context.Context, l *slog.Logger, fltPath string) {
err := os.Remove(fltPath + ".old")
if err == nil {
return
}
lvl := slog.LevelWarn
if errors.Is(err, os.ErrNotExist) {
lvl = slog.LevelDebug
}
l.Log(ctx, lvl, "removing old filter", "path", fltPath, slogutil.KeyError, err)
}
// update refreshes filter's content and a/mtimes of it's file.
func (d *DNSFilter) update(filter *FilterYAML) (b bool, err error) {
ctx := context.TODO()