diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 82d831ad..30323898 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -20,7 +20,5 @@ jobs: uses: golangci/golangci-lint-action@v6 with: skip-cache: true - skip-pkg-cache: true - skip-build-cache: true version: latest args: --timeout=30m ./... diff --git a/.goreleaser.yaml b/.goreleaser.yaml index a1bef805..93a3e223 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -34,7 +34,7 @@ archives: - panel format: zip wrap_in_directory: false - strip_parent_binary_folder: true + strip_binary_directory: true files: - LICENSE - docs/* diff --git a/app/http/controllers/file_controller.go b/app/http/controllers/file_controller.go index 86e2d77c..02edde05 100644 --- a/app/http/controllers/file_controller.go +++ b/app/http/controllers/file_controller.go @@ -353,7 +353,7 @@ func (r *FileController) Permission(ctx http.Context) http.Response { return sanitize } - if err := tools.Chmod(request.Path, os.FileMode(request.Mode)); err != nil { + if err := tools.Chmod(request.Path, request.Mode); err != nil { return Error(ctx, http.StatusInternalServerError, err.Error()) } if err := tools.Chown(request.Path, request.Owner, request.Group); err != nil { @@ -523,6 +523,6 @@ func (r *FileController) List(ctx http.Context) http.Response { // setPermission func (r *FileController) setPermission(path string, mode uint, owner, group string) { - _ = tools.Chmod(path, os.FileMode(mode)) + _ = tools.Chmod(path, mode) _ = tools.Chown(path, owner, group) } diff --git a/pkg/tools/system.go b/pkg/tools/system.go index 6cbb7488..1fcbe544 100644 --- a/pkg/tools/system.go +++ b/pkg/tools/system.go @@ -112,8 +112,13 @@ func Mkdir(path string, permission os.FileMode) error { } // Chmod 修改文件/目录权限 -func Chmod(path string, permission os.FileMode) error { - return os.Chmod(path, permission) +func Chmod(path string, permission uint) error { + if env.IsWindows() { + return errors.New("chmod is not supported on Windows") + } + + cmd := exec.Command("chmod", "-R", cast.ToString(permission), path) + return cmd.Run() } // Chown 修改文件或目录所有者