Improve geoip database downloading and do not block connections

This commit is contained in:
Patrick Pacher
2021-08-18 15:28:50 +02:00
parent 26608c2e21
commit c02f2cb593
3 changed files with 189 additions and 130 deletions

View File

@@ -20,23 +20,9 @@ func prep() error {
updates.ModuleName,
updates.ResourceUpdateEvent,
"Check for GeoIP database updates",
upgradeDatabases,
func(c context.Context, i interface{}) error {
worker.triggerUpdate()
return nil
},
)
}
func upgradeDatabases(_ context.Context, _ interface{}) error {
dbFileLock.Lock()
reload := false
if geoDBv4File != nil && geoDBv4File.UpgradeAvailable() {
reload = true
}
if geoDBv6File != nil && geoDBv6File.UpgradeAvailable() {
reload = true
}
dbFileLock.Unlock()
if reload {
return ReloadDatabases()
}
return nil
}