1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-09 09:20:45 +00:00

Fix: v2ray.location.asset env not working (#889)

This commit is contained in:
Loyalsoldier 2021-04-12 10:01:30 +08:00 committed by GitHub
parent 098bf4bc21
commit 7790d33185
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 13 deletions

View File

@ -2,6 +2,7 @@ package router_test
import (
"errors"
"io/fs"
"os"
"path/filepath"
"strings"
@ -25,8 +26,8 @@ func init() {
os.Setenv("v2ray.location.asset", tempPath)
if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && errors.Is(err, os.ErrNotExist) {
if _, err := os.Stat(geoipPath); err != nil && errors.Is(err, os.ErrNotExist) {
if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && errors.Is(err, fs.ErrNotExist) {
if _, err := os.Stat(geoipPath); err != nil && errors.Is(err, fs.ErrNotExist) {
common.Must(os.MkdirAll(tempPath, 0755))
geoipBytes, err := common.FetchHTTPContent(geoipURL)
common.Must(err)

View File

@ -2,6 +2,7 @@ package router_test
import (
"errors"
"io/fs"
"os"
"path/filepath"
"strconv"
@ -32,8 +33,8 @@ func init() {
os.Setenv("v2ray.location.asset", tempPath)
if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && errors.Is(err, os.ErrNotExist) {
if _, err := os.Stat(geoipPath); err != nil && errors.Is(err, os.ErrNotExist) {
if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && errors.Is(err, fs.ErrNotExist) {
if _, err := os.Stat(geoipPath); err != nil && errors.Is(err, fs.ErrNotExist) {
common.Must(os.MkdirAll(tempPath, 0755))
geoipBytes, err := common.FetchHTTPContent(geoipURL)
common.Must(err)
@ -41,8 +42,8 @@ func init() {
}
}
if _, err := os.Stat(platform.GetAssetLocation("geosite.dat")); err != nil && errors.Is(err, os.ErrNotExist) {
if _, err := os.Stat(geositePath); err != nil && errors.Is(err, os.ErrNotExist) {
if _, err := os.Stat(platform.GetAssetLocation("geosite.dat")); err != nil && errors.Is(err, fs.ErrNotExist) {
if _, err := os.Stat(geositePath); err != nil && errors.Is(err, fs.ErrNotExist) {
common.Must(os.MkdirAll(tempPath, 0755))
geositeBytes, err := common.FetchHTTPContent(geositeURL)
common.Must(err)

View File

@ -4,6 +4,7 @@ package platform
import (
"errors"
"io/fs"
"os"
"path/filepath"
)
@ -33,7 +34,7 @@ func GetAssetLocation(file string) string {
filepath.Join("/usr/share/v2ray/", file),
filepath.Join("/opt/share/v2ray/", file),
} {
if _, err := os.Stat(p); err != nil && errors.Is(os.ErrNotExist, err) {
if _, err := os.Stat(p); err != nil && errors.Is(err, fs.ErrNotExist) {
continue
}

View File

@ -3,6 +3,7 @@ package conf_test
import (
"encoding/json"
"errors"
"io/fs"
"os"
"path/filepath"
"testing"
@ -27,8 +28,8 @@ func init() {
os.Setenv("v2ray.location.asset", tempPath)
if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && errors.Is(err, os.ErrNotExist) {
if _, err := os.Stat(geoipPath); err != nil && errors.Is(err, os.ErrNotExist) {
if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && errors.Is(err, fs.ErrNotExist) {
if _, err := os.Stat(geoipPath); err != nil && errors.Is(err, fs.ErrNotExist) {
common.Must(os.MkdirAll(tempPath, 0755))
geoipBytes, err := common.FetchHTTPContent(geoipURL)
common.Must(err)
@ -36,8 +37,8 @@ func init() {
}
}
if _, err := os.Stat(platform.GetAssetLocation("geosite.dat")); err != nil && errors.Is(err, os.ErrNotExist) {
if _, err := os.Stat(geositePath); err != nil && errors.Is(err, os.ErrNotExist) {
if _, err := os.Stat(platform.GetAssetLocation("geosite.dat")); err != nil && errors.Is(err, fs.ErrNotExist) {
if _, err := os.Stat(geositePath); err != nil && errors.Is(err, fs.ErrNotExist) {
common.Must(os.MkdirAll(tempPath, 0755))
geositeBytes, err := common.FetchHTTPContent(geositeURL)
common.Must(err)

View File

@ -3,6 +3,7 @@ package conf_test
import (
"encoding/json"
"errors"
"io/fs"
"os"
"path/filepath"
"testing"
@ -27,8 +28,8 @@ func init() {
os.Setenv("v2ray.location.asset", tempPath)
if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && errors.Is(err, os.ErrNotExist) {
if _, err := os.Stat(geoipPath); err != nil && errors.Is(err, os.ErrNotExist) {
if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && errors.Is(err, fs.ErrNotExist) {
if _, err := os.Stat(geoipPath); err != nil && errors.Is(err, fs.ErrNotExist) {
common.Must(os.MkdirAll(tempPath, 0755))
geoipBytes, err := common.FetchHTTPContent(geoipURL)
common.Must(err)