mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-22 16:41:30 +00:00
Fix download geo resources
This commit is contained in:
parent
11629a931b
commit
9f01d5c5b4
|
@ -157,12 +157,6 @@ func (r *Router) downloadGeoIPDatabase(savePath string) error {
|
||||||
filemanager.MkdirAll(r.ctx, parentDir, 0o755)
|
filemanager.MkdirAll(r.ctx, parentDir, 0o755)
|
||||||
}
|
}
|
||||||
|
|
||||||
saveFile, err := filemanager.Create(r.ctx, savePath)
|
|
||||||
if err != nil {
|
|
||||||
return E.Cause(err, "open output file: ", downloadURL)
|
|
||||||
}
|
|
||||||
defer saveFile.Close()
|
|
||||||
|
|
||||||
httpClient := &http.Client{
|
httpClient := &http.Client{
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
ForceAttemptHTTP2: true,
|
ForceAttemptHTTP2: true,
|
||||||
|
@ -182,7 +176,16 @@ func (r *Router) downloadGeoIPDatabase(savePath string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
saveFile, err := filemanager.Create(r.ctx, savePath)
|
||||||
|
if err != nil {
|
||||||
|
return E.Cause(err, "open output file: ", downloadURL)
|
||||||
|
}
|
||||||
_, err = io.Copy(saveFile, response.Body)
|
_, err = io.Copy(saveFile, response.Body)
|
||||||
|
saveFile.Close()
|
||||||
|
if err != nil {
|
||||||
|
filemanager.Remove(r.ctx, savePath)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,12 +212,6 @@ func (r *Router) downloadGeositeDatabase(savePath string) error {
|
||||||
filemanager.MkdirAll(r.ctx, parentDir, 0o755)
|
filemanager.MkdirAll(r.ctx, parentDir, 0o755)
|
||||||
}
|
}
|
||||||
|
|
||||||
saveFile, err := filemanager.Create(r.ctx, savePath)
|
|
||||||
if err != nil {
|
|
||||||
return E.Cause(err, "open output file: ", downloadURL)
|
|
||||||
}
|
|
||||||
defer saveFile.Close()
|
|
||||||
|
|
||||||
httpClient := &http.Client{
|
httpClient := &http.Client{
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
ForceAttemptHTTP2: true,
|
ForceAttemptHTTP2: true,
|
||||||
|
@ -234,7 +231,16 @@ func (r *Router) downloadGeositeDatabase(savePath string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
saveFile, err := filemanager.Create(r.ctx, savePath)
|
||||||
|
if err != nil {
|
||||||
|
return E.Cause(err, "open output file: ", downloadURL)
|
||||||
|
}
|
||||||
_, err = io.Copy(saveFile, response.Body)
|
_, err = io.Copy(saveFile, response.Body)
|
||||||
|
saveFile.Close()
|
||||||
|
if err != nil {
|
||||||
|
filemanager.Remove(r.ctx, savePath)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue