Skip to content

Commit

Permalink
Allow setting permission on CopyFile helper
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaokangwang committed Mar 11, 2024
1 parent cc79bbe commit d84da75
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions common/platform/filesystem/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ func ReadAsset(file string) ([]byte, error) {
return ReadFile(platform.GetAssetLocation(file))
}

func CopyFile(dst string, src string) error {
func CopyFile(dst string, src string, perm os.FileMode) error {
bytes, err := ReadFile(src)
if err != nil {
return err
}
f, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY, 0o644)
f, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY, perm)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion infra/conf/rule/rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func init() {
func TestToCidrList(t *testing.T) {
t.Log(os.Getenv("v2ray.location.asset"))

common.Must(filesystem.CopyFile(platform.GetAssetLocation("geoiptestrouter.dat"), platform.GetAssetLocation("geoip.dat")))
common.Must(filesystem.CopyFile(platform.GetAssetLocation("geoiptestrouter.dat"), platform.GetAssetLocation("geoip.dat"), 0o600))

ips := cfgcommon.StringList([]string{
"geoip:us",
Expand Down

0 comments on commit d84da75

Please sign in to comment.