Skip to content

Commit

Permalink
修复文件夹权限问题
Browse files Browse the repository at this point in the history
  • Loading branch information
50percent committed Oct 23, 2019
1 parent 10789c8 commit bbf19d1
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion NetCoreBeautyNuget/NetCoreBeauty.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>nulastudio.NetCoreBeauty</id>
<description>Move a .NET Core app runtime components and dependencies into a sub-directory and make it beauty.</description>
<version>1.1.0</version>
<version>1.1.1</version>
<authors>LiesAuer</authors>
<owners>nulastudio</owners>
<projectUrl>https://github.com/nulastudio/NetCoreBeauty</projectUrl>
Expand Down
2 changes: 1 addition & 1 deletion NetCoreBeautyNugetTest/NetCoreBeautyTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="nulastudio.NetCoreBeauty" Version="1.1.0" />
<PackageReference Include="nulastudio.NetCoreBeauty" Version="1.1.1" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ your `*.csproj` should be similar like this
</PropertyGroup>

<ItemGroup>
<PackageReference Include="nulastudio.NetCoreBeauty" Version="1.1.0" />
<PackageReference Include="nulastudio.NetCoreBeauty" Version="1.1.1" />
</ItemGroup>

</Project>
Expand Down
2 changes: 2 additions & 0 deletions src/main/beauty.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ var beautyDir string
var libsDir = "runtimes"

func main() {
Umask()

initCLI()

// 设置CDN
Expand Down
11 changes: 11 additions & 0 deletions src/main/umask_nonwindows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build !windows

package main

import (
"syscall"
)

func Umask() {
syscall.Umask(0)
}
3 changes: 3 additions & 0 deletions src/main/umask_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package main

func Umask() {}
10 changes: 5 additions & 5 deletions src/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var Logger = log.DefaultLogger

var timeout = 60 * time.Second

var localPath = os.TempDir() + "/NetCoreBeauty"
var localPath = filepath.Clean(os.TempDir()) + "/NetCoreBeauty"
var localArtifactsPath = localPath + "/artifacts"
var artifactsVersionTXT = "/ArtifactsVersion.txt"
var artifactsVersionJSON = "/ArtifactsVersion.json"
Expand Down Expand Up @@ -124,7 +124,7 @@ func readLocalArtifactsVersionJSON() map[string]interface{} {
}

func updateLocalArtifactsVersionJSON(data map[string]interface{}) bool {
if !util.EnsureDirExists(localArtifactsPath, 0666) {
if !util.EnsureDirExists(localArtifactsPath, 0777) {
log.LogError(fmt.Errorf(pathNotWriteableErr, localArtifactsPath), false)
return false
}
Expand Down Expand Up @@ -172,7 +172,7 @@ func getLocalRuntimeSupportedVersion() string {

// WriteLocalArtifactsVersion 更新本地补丁版本
func WriteLocalArtifactsVersion(fxrVersion string, rid string, version string) bool {
if !util.EnsureDirExists(localArtifactsPath, 0666) {
if !util.EnsureDirExists(localArtifactsPath, 0777) {
log.LogError(fmt.Errorf(pathNotWriteableErr, localArtifactsPath), false)
return false
}
Expand Down Expand Up @@ -277,8 +277,8 @@ func DownloadFile(url string, des string) bool {
} else {
des = strings.ReplaceAll(des, "\\", "/")
path := path.Dir(des)
if !util.EnsureDirExists(path, 0666) {
log.LogError(errors.New(pathNotWriteableErr+path), false)
if !util.EnsureDirExists(path, 0777) {
log.LogError(fmt.Errorf(pathNotWriteableErr, path), false)
} else {
f, err := os.Create(des)
defer f.Close()
Expand Down
2 changes: 1 addition & 1 deletion src/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func CopyFile(src string, des string) (written int64, err error) {
perm := fi.Mode()

dir := filepath.Dir(des)
if !EnsureDirExists(dir, perm) {
if !EnsureDirExists(dir, 0777) {
return 0, errors.New("cannot create path: " + dir)
}

Expand Down

0 comments on commit bbf19d1

Please sign in to comment.