chore: better getUpdateTime() for iterating all Geofiles (#1570)

This commit is contained in:
ForestL 2024-10-11 08:46:31 +08:00 committed by GitHub
parent 57725078e0
commit 4437c8861c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -229,20 +229,22 @@ func UpdateGeoDatabases() error {
}
func getUpdateTime() (err error, time time.Time) {
var fileInfo os.FileInfo
if geodata.GeodataMode() {
fileInfo, err = os.Stat(C.Path.GeoIP())
if err != nil {
return err, time
}
} else {
fileInfo, err = os.Stat(C.Path.MMDB())
if err != nil {
return err, time
filesToCheck := []string{
C.Path.GeoIP(),
C.Path.MMDB(),
C.Path.ASN(),
C.Path.GeoSite(),
}
for _, file := range filesToCheck {
var fileInfo os.FileInfo
fileInfo, err = os.Stat(file)
if err == nil {
return nil, fileInfo.ModTime()
}
}
return nil, fileInfo.ModTime()
return
}
func RegisterGeoUpdater() {