mirror of
https://github.com/MetaCubeX/Clash.Meta.git
synced 2025-04-06 06:33:31 +03:00
Fix: provider fallback should reparse proxies
This commit is contained in:
parent
609869bf5a
commit
9eaca6e4ab
1 changed files with 11 additions and 0 deletions
|
@ -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…
Add table
Reference in a new issue