Skip to content

Commit

Permalink
feat: load previous download when download fail
Browse files Browse the repository at this point in the history
  • Loading branch information
haruue committed Feb 21, 2024
1 parent 6dea0ad commit 842b0ab
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/internal/utils/geoloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ func (l *GeoLoader) LoadGeoIP() (map[string]*v2geo.GeoIP, error) {
return err
})
if err != nil {
return nil, err
// as long as the previous download exists, fallback to it
if _, serr := os.Stat(filename); os.IsNotExist(serr) {
return nil, err
}
}
}
m, err := v2geo.LoadGeoIP(filename)
Expand Down Expand Up @@ -154,7 +157,10 @@ func (l *GeoLoader) LoadGeoSite() (map[string]*v2geo.GeoSite, error) {
return err
})
if err != nil {
return nil, err
// as long as the previous download exists, fallback to it
if _, serr := os.Stat(filename); os.IsNotExist(serr) {
return nil, err
}
}
}
m, err := v2geo.LoadGeoSite(filename)
Expand Down

0 comments on commit 842b0ab

Please sign in to comment.