mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-12-13 14:34:35 +03:00
Pull request 2283: AG-27492-fix-safesearch-cache
Squashed commit of the following:
commit c93ee78c05fae78c99796acfdfcfb4755469e37f
Merge: 8019871a9 557898788
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Wed Oct 2 20:41:52 2024 +0300
Merge branch 'master' into AG-27492-fix-safesearch-cache
commit 8019871a93b1326cdc3475f49198bc28f194a097
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Wed Oct 2 15:31:37 2024 +0300
home: fix safesearch cache
This commit is contained in:
parent
5578987884
commit
5b5b397132
@ -72,10 +72,13 @@ func (clients *clientsContainer) Init(
|
||||
return errors.Error("clients container already initialized")
|
||||
}
|
||||
|
||||
clients.safeSearchCacheSize = filteringConf.SafeSearchCacheSize
|
||||
clients.safeSearchCacheTTL = time.Minute * time.Duration(filteringConf.CacheTime)
|
||||
|
||||
confClients := make([]*client.Persistent, 0, len(objects))
|
||||
for i, o := range objects {
|
||||
var p *client.Persistent
|
||||
p, err = o.toPersistent(filteringConf)
|
||||
p, err = o.toPersistent(clients.safeSearchCacheSize, clients.safeSearchCacheTTL)
|
||||
if err != nil {
|
||||
return fmt.Errorf("init persistent client at index %d: %w", i, err)
|
||||
}
|
||||
@ -165,7 +168,8 @@ type clientObject struct {
|
||||
|
||||
// toPersistent returns an initialized persistent client if there are no errors.
|
||||
func (o *clientObject) toPersistent(
|
||||
filteringConf *filtering.Config,
|
||||
safeSearchCacheSize uint,
|
||||
safeSearchCacheTTL time.Duration,
|
||||
) (cli *client.Persistent, err error) {
|
||||
cli = &client.Persistent{
|
||||
Name: o.Name,
|
||||
@ -201,8 +205,8 @@ func (o *clientObject) toPersistent(
|
||||
if o.SafeSearchConf.Enabled {
|
||||
err = cli.SetSafeSearch(
|
||||
o.SafeSearchConf,
|
||||
filteringConf.SafeSearchCacheSize,
|
||||
time.Minute*time.Duration(filteringConf.CacheTime),
|
||||
safeSearchCacheSize,
|
||||
safeSearchCacheTTL,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init safesearch %q: %w", cli.Name, err)
|
||||
|
Loading…
Reference in New Issue
Block a user