Skip to content

Commit

Permalink
chore: better getUpdateTime() for iterating all Geofiles (#1570)
Browse files Browse the repository at this point in the history
  • Loading branch information
ForestL18 authored Oct 11, 2024
1 parent 5772507 commit 4437c88
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions component/updater/update_geo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 4437c88

Please sign in to comment.