chore: close file descriptor & remove duplicated error handle (#303)

This commit is contained in:
douglarek 2023-08-28 23:09:50 +08:00 committed by GitHub
parent 0010ccb675
commit a333079686
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -106,6 +106,7 @@ func ResolveFile(u *url.URL, configDir string) (b []byte, err error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
defer f.Close()
// Check file access. // Check file access.
fi, err := f.Stat() fi, err := f.Stat()
if err != nil { if err != nil {
@ -167,9 +168,6 @@ func ResolveSubscription(log *logrus.Logger, client *http.Client, configDir stri
return "", nil, err return "", nil, err
} }
req.Header.Set("User-Agent", fmt.Sprintf("dae/%v (like v2rayA/1.0 WebRequestHelper) (like v2rayN/1.0 WebRequestHelper)", config.Version)) req.Header.Set("User-Agent", fmt.Sprintf("dae/%v (like v2rayA/1.0 WebRequestHelper) (like v2rayN/1.0 WebRequestHelper)", config.Version))
if err != nil {
return "", nil, err
}
resp, err = client.Do(req) resp, err = client.Do(req)
if err != nil { if err != nil {
return "", nil, err return "", nil, err