mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-02-28 13:13:00 +00:00
style: improve formatting in UpdateGeofile function
This commit is contained in:
parent
0e986b97d2
commit
41d0278ed2
1 changed files with 4 additions and 3 deletions
|
|
@ -1087,12 +1087,14 @@ func (s *ServerService) UpdateGeofile(fileName string) error {
|
||||||
return common.NewErrorf("Invalid geofile name: %s not in allowlist", fileName)
|
return common.NewErrorf("Invalid geofile name: %s not in allowlist", fileName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadFile := func(url, destPath string) error {
|
downloadFile := func(url, destPath string) error {
|
||||||
var req *http.Request
|
var req *http.Request
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.NewErrorf("Failed to create HTTP request for %s: %v", url, err)
|
return common.NewErrorf("Failed to create HTTP request for %s: %v", url, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var localFileModTime time.Time
|
var localFileModTime time.Time
|
||||||
if fileInfo, err := os.Stat(destPath); err == nil {
|
if fileInfo, err := os.Stat(destPath); err == nil {
|
||||||
localFileModTime = fileInfo.ModTime()
|
localFileModTime = fileInfo.ModTime()
|
||||||
|
|
@ -1160,7 +1162,6 @@ func (s *ServerService) UpdateGeofile(fileName string) error {
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
// Sanitize the filename from our allowlist as an extra precaution
|
// Sanitize the filename from our allowlist as an extra precaution
|
||||||
destPath := filepath.Join(config.GetBinFolderPath(), filepath.Base(file.FileName))
|
destPath := filepath.Join(config.GetBinFolderPath(), filepath.Base(file.FileName))
|
||||||
|
|
||||||
if err := downloadFile(file.URL, destPath); err != nil {
|
if err := downloadFile(file.URL, destPath); err != nil {
|
||||||
errorMessages = append(errorMessages, fmt.Sprintf("Error downloading Geofile '%s': %v", file.FileName, err))
|
errorMessages = append(errorMessages, fmt.Sprintf("Error downloading Geofile '%s': %v", file.FileName, err))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue