aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-04-24 18:20:22 +0200
committerGitHub <noreply@github.com>2020-04-24 19:20:22 +0300
commit4ddfe0d07acd65c25c6a301faf16f175de0e46bf (patch)
treecc8f85f0fd56ee28f555b0c407ca61919a227329 /routers
parent812cfd0ad9bb85b13ce77f611b3c80dad371d1ef (diff)
downloadgitea-4ddfe0d07acd65c25c6a301faf16f175de0e46bf.tar.gz
gitea-4ddfe0d07acd65c25c6a301faf16f175de0e46bf.zip
Fix GetContents(): Dont't ignore Executables (#11192)
* Refactor: dont expose help functions * repofiles GetContents: dont ignore executables * CI.restart()
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/file.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go
index d409a28489..02a7de9b58 100644
--- a/routers/api/v1/repo/file.go
+++ b/routers/api/v1/repo/file.go
@@ -155,13 +155,13 @@ func GetEditorconfig(ctx *context.APIContext) {
ctx.JSON(http.StatusOK, def)
}
-// CanWriteFiles returns true if repository is editable and user has proper access level.
-func CanWriteFiles(r *context.Repository) bool {
+// canWriteFiles returns true if repository is editable and user has proper access level.
+func canWriteFiles(r *context.Repository) bool {
return r.Permission.CanWrite(models.UnitTypeCode) && !r.Repository.IsMirror && !r.Repository.IsArchived
}
-// CanReadFiles returns true if repository is readable and user has proper access level.
-func CanReadFiles(r *context.Repository) bool {
+// canReadFiles returns true if repository is readable and user has proper access level.
+func canReadFiles(r *context.Repository) bool {
return r.Permission.CanRead(models.UnitTypeCode)
}
@@ -321,7 +321,7 @@ func UpdateFile(ctx *context.APIContext, apiOpts api.UpdateFileOptions) {
// Called from both CreateFile or UpdateFile to handle both
func createOrUpdateFile(ctx *context.APIContext, opts *repofiles.UpdateRepoFileOptions) (*api.FileResponse, error) {
- if !CanWriteFiles(ctx.Repo) {
+ if !canWriteFiles(ctx.Repo) {
return nil, models.ErrUserDoesNotHaveAccessToRepo{
UserID: ctx.User.ID,
RepoName: ctx.Repo.Repository.LowerName,
@@ -377,7 +377,7 @@ func DeleteFile(ctx *context.APIContext, apiOpts api.DeleteFileOptions) {
// "404":
// "$ref": "#/responses/error"
- if !CanWriteFiles(ctx.Repo) {
+ if !canWriteFiles(ctx.Repo) {
ctx.Error(http.StatusForbidden, "DeleteFile", models.ErrUserDoesNotHaveAccessToRepo{
UserID: ctx.User.ID,
RepoName: ctx.Repo.Repository.LowerName,
@@ -474,7 +474,7 @@ func GetContents(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- if !CanReadFiles(ctx.Repo) {
+ if !canReadFiles(ctx.Repo) {
ctx.Error(http.StatusInternalServerError, "GetContentsOrList", models.ErrUserDoesNotHaveAccessToRepo{
UserID: ctx.User.ID,
RepoName: ctx.Repo.Repository.LowerName,