mirror of
https://github.com/go-gitea/gitea.git
synced 2025-12-08 15:45:27 +01:00
Safely handle map deletions in refreshAccesses to avoid iteration issues
This commit is contained in:
parent
f600226a04
commit
7d46b0969a
@ -105,8 +105,10 @@ func refreshAccesses(ctx context.Context, repo *repo_model.Repository, accessMap
|
|||||||
}
|
}
|
||||||
|
|
||||||
newAccesses := make([]Access, 0, len(accessMap))
|
newAccesses := make([]Access, 0, len(accessMap))
|
||||||
|
keysToDelete := []int64{}
|
||||||
for userID, ua := range accessMap {
|
for userID, ua := range accessMap {
|
||||||
if ua.Mode < minMode && !ua.User.IsRestricted {
|
if ua.Mode < minMode && !ua.User.IsRestricted {
|
||||||
|
keysToDelete = append(keysToDelete, userID)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,6 +118,9 @@ func refreshAccesses(ctx context.Context, repo *repo_model.Repository, accessMap
|
|||||||
Mode: ua.Mode,
|
Mode: ua.Mode,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
for _, uid := range keysToDelete {
|
||||||
|
delete(accessMap, uid)
|
||||||
|
}
|
||||||
|
|
||||||
// Delete old accesses and insert new ones for repository.
|
// Delete old accesses and insert new ones for repository.
|
||||||
if _, err = db.DeleteByBean(ctx, &Access{RepoID: repo.ID}); err != nil {
|
if _, err = db.DeleteByBean(ctx, &Access{RepoID: repo.ID}); err != nil {
|
||||||
|
|||||||
@ -726,9 +726,24 @@ func GetWorkflowRunLogsStream(ctx *context.APIContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jobID := ctx.FormInt64("job_id")
|
||||||
jobIndex := int64(0)
|
jobIndex := int64(0)
|
||||||
if ctx.FormInt("job") > 0 {
|
if jobID > 0 {
|
||||||
jobIndex = int64(ctx.FormInt("job"))
|
jobs, err := getRunJobsByRunID(ctx, runID)
|
||||||
|
if err != nil {
|
||||||
|
ctx.APIErrorInternal(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for i, j := range jobs {
|
||||||
|
if j.ID == jobID {
|
||||||
|
jobIndex = int64(i)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if jobIndex == 0 && jobID > 0 {
|
||||||
|
ctx.APIError(404, "Job not found")
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse log cursors from request body
|
// Parse log cursors from request body
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"code.gitea.io/gitea/build/codeformat"
|
"code.gitea.io/gitea/tools/codeformat"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Windows has a limitation for command line arguments, the size can not exceed 32KB.
|
// Windows has a limitation for command line arguments, the size can not exceed 32KB.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user