mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
Fix: provider fallback should reparse proxies
This commit is contained in:
parent
609869bf5a
commit
9eaca6e4ab
|
@ -114,10 +114,12 @@ func (pp *ProxySetProvider) Destroy() error {
|
|||
func (pp *ProxySetProvider) Initial() error {
|
||||
var buf []byte
|
||||
var err error
|
||||
var isLocal bool
|
||||
if stat, err := os.Stat(pp.vehicle.Path()); err == nil {
|
||||
buf, err = ioutil.ReadFile(pp.vehicle.Path())
|
||||
modTime := stat.ModTime()
|
||||
pp.updatedAt = &modTime
|
||||
isLocal = true
|
||||
} else {
|
||||
buf, err = pp.vehicle.Read()
|
||||
}
|
||||
|
@ -128,11 +130,20 @@ func (pp *ProxySetProvider) Initial() error {
|
|||
|
||||
proxies, err := pp.parse(buf)
|
||||
if err != nil {
|
||||
if !isLocal {
|
||||
return err
|
||||
}
|
||||
|
||||
// parse local file error, fallback to remote
|
||||
buf, err = pp.vehicle.Read()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
proxies, err = pp.parse(buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(pp.vehicle.Path(), buf, fileMode); err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user