mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 03:32:33 +08:00
chore: better getUpdateTime() for iterating all Geofiles (#1570)
Some checks failed
Trigger CMFA Update / trigger-CMFA-update (push) Has been cancelled
Some checks failed
Trigger CMFA Update / trigger-CMFA-update (push) Has been cancelled
This commit is contained in:
parent
57725078e0
commit
4437c8861c
|
@ -229,20 +229,22 @@ func UpdateGeoDatabases() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUpdateTime() (err error, time time.Time) {
|
func getUpdateTime() (err error, time time.Time) {
|
||||||
var fileInfo os.FileInfo
|
filesToCheck := []string{
|
||||||
if geodata.GeodataMode() {
|
C.Path.GeoIP(),
|
||||||
fileInfo, err = os.Stat(C.Path.GeoIP())
|
C.Path.MMDB(),
|
||||||
if err != nil {
|
C.Path.ASN(),
|
||||||
return err, time
|
C.Path.GeoSite(),
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
fileInfo, err = os.Stat(C.Path.MMDB())
|
for _, file := range filesToCheck {
|
||||||
if err != nil {
|
var fileInfo os.FileInfo
|
||||||
return err, time
|
fileInfo, err = os.Stat(file)
|
||||||
|
if err == nil {
|
||||||
|
return nil, fileInfo.ModTime()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, fileInfo.ModTime()
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterGeoUpdater() {
|
func RegisterGeoUpdater() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user