Skip to content

Commit 4437c88

Browse files
authored
chore: better getUpdateTime() for iterating all Geofiles (#1570)
1 parent 5772507 commit 4437c88

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

component/updater/update_geo.go

+13-11
Original file line numberDiff line numberDiff line change
@@ -229,20 +229,22 @@ func UpdateGeoDatabases() error {
229229
}
230230

231231
func getUpdateTime() (err error, time time.Time) {
232-
var fileInfo os.FileInfo
233-
if geodata.GeodataMode() {
234-
fileInfo, err = os.Stat(C.Path.GeoIP())
235-
if err != nil {
236-
return err, time
237-
}
238-
} else {
239-
fileInfo, err = os.Stat(C.Path.MMDB())
240-
if err != nil {
241-
return err, time
232+
filesToCheck := []string{
233+
C.Path.GeoIP(),
234+
C.Path.MMDB(),
235+
C.Path.ASN(),
236+
C.Path.GeoSite(),
237+
}
238+
239+
for _, file := range filesToCheck {
240+
var fileInfo os.FileInfo
241+
fileInfo, err = os.Stat(file)
242+
if err == nil {
243+
return nil, fileInfo.ModTime()
242244
}
243245
}
244246

245-
return nil, fileInfo.ModTime()
247+
return
246248
}
247249

248250
func RegisterGeoUpdater() {

0 commit comments

Comments
 (0)