···1212 repo_model "code.gitea.io/gitea/models/repo"
1313 user_model "code.gitea.io/gitea/models/user"
1414 "code.gitea.io/gitea/modules/timeutil"
1515+ "code.gitea.io/gitea/modules/util"
1516 webhook_module "code.gitea.io/gitea/modules/webhook"
1617)
1718···67686869 // Loop through each schedule row
6970 for _, row := range rows {
7171+ row.Title, _ = util.SplitStringAtByteN(row.Title, 255)
7072 // Create new schedule row
7173 if err = db.Insert(ctx, row); err != nil {
7274 return err
+3-1
models/actions/task.go
···341341// UpdateTaskByState updates the task by the state.
342342// It will always update the task if the state is not final, even there is no change.
343343// So it will update ActionTask.Updated to avoid the task being judged as a zombie task.
344344-func UpdateTaskByState(ctx context.Context, state *runnerv1.TaskState) (*ActionTask, error) {
344344+func UpdateTaskByState(ctx context.Context, runnerID int64, state *runnerv1.TaskState) (*ActionTask, error) {
345345 stepStates := map[int64]*runnerv1.StepState{}
346346 for _, v := range state.Steps {
347347 stepStates[v.Id] = v
···360360 return nil, err
361361 } else if !has {
362362 return nil, util.ErrNotExist
363363+ } else if runnerID != task.RunnerID {
364364+ return nil, fmt.Errorf("invalid runner for task")
363365 }
364366365367 if task.Status.IsDone() {
+6
models/activities/action.go
···250250// GetRepoUserName returns the name of the action repository owner.
251251func (a *Action) GetRepoUserName(ctx context.Context) string {
252252 a.loadRepo(ctx)
253253+ if a.Repo == nil {
254254+ return "(non-existing-repo)"
255255+ }
253256 return a.Repo.OwnerName
254257}
255258···262265// GetRepoName returns the name of the action repository.
263266func (a *Action) GetRepoName(ctx context.Context) string {
264267 a.loadRepo(ctx)
268268+ if a.Repo == nil {
269269+ return "(non-existing-repo)"
270270+ }
265271 return a.Repo.Name
266272}
267273
+4
models/issues/issue_update.go
···2121 "code.gitea.io/gitea/modules/references"
2222 api "code.gitea.io/gitea/modules/structs"
2323 "code.gitea.io/gitea/modules/timeutil"
2424+ "code.gitea.io/gitea/modules/util"
24252526 "xorm.io/builder"
2627)
···154155 }
155156 defer committer.Close()
156157158158+ issue.Title, _ = util.SplitStringAtByteN(issue.Title, 255)
157159 if err = UpdateIssueCols(ctx, issue, "name"); err != nil {
158160 return fmt.Errorf("updateIssueCols: %w", err)
159161 }
···409411}
410412411413// NewIssue creates new issue with labels for repository.
414414+// The title will be cut off at 255 characters if it's longer than 255 characters.
412415func NewIssue(ctx context.Context, repo *repo_model.Repository, issue *Issue, labelIDs []int64, uuids []string) (err error) {
413416 ctx, committer, err := db.TxContext(ctx)
414417 if err != nil {
···422425 }
423426424427 issue.Index = idx
428428+ issue.Title, _ = util.SplitStringAtByteN(issue.Title, 255)
425429426430 if err = NewIssueWithIndex(ctx, issue.Poster, NewIssueOptions{
427431 Repo: repo,
···11+fix(security): [commit](https://codeberg.org/forgejo/forgejo/commit/45435a8789f8ff69603799a9031246d2d621d139) Fix and refactor markdown rendering
22+fix: [commit](https://codeberg.org/forgejo/forgejo/commit/a8f2002a9b061ec1092df67c6f05e30aa7d2e2d2) Remove transaction for archive download
33+fix: [commit](https://codeberg.org/forgejo/forgejo/commit/96ee0f56475204b2bbdc7f2aeb35b1c32eac469c) Fix oauth2 error handle not return immediately
44+fix: [commit](https://codeberg.org/forgejo/forgejo/commit/c2e8790df37a14b4d2f72c7377db75309e0ebf1d) Trim title before insert/update to database to match the size requirements of database
55+fix: [commit](https://codeberg.org/forgejo/forgejo/commit/03ab73d92eabaf774278effe3332623b1dc3580a) Fix nil panic if repo doesn't exist
66+fix: [commit](https://codeberg.org/forgejo/forgejo/commit/56971f9ed90a01fd74a634b7496593e6f62ac260) Disable Oauth check if oauth disabled
77+fix: [commit](https://codeberg.org/forgejo/forgejo/commit/7f51210672031aee7a790455d51a17ce11a70559) Harden runner updateTask and updateLog api
88+feat: [commit](https://codeberg.org/forgejo/forgejo/commit/dd3c4d7096cff91854bcc6641f55d9d093e5c86e) Add a doctor check to disable the "Actions" unit for mirrors
···6969}
70707171// NewRequest creates an archival request, based on the URI. The
7272-// resulting ArchiveRequest is suitable for being passed to ArchiveRepository()
7272+// resulting ArchiveRequest is suitable for being passed to Await()
7373// if it's determined that the request still needs to be satisfied.
7474func NewRequest(ctx context.Context, repoID int64, repo *git.Repository, uri string) (*ArchiveRequest, error) {
7575 r := &ArchiveRequest{
···168168 }
169169}
170170171171+// doArchive satisfies the ArchiveRequest being passed in. Processing
172172+// will occur in a separate goroutine, as this phase may take a while to
173173+// complete. If the archive already exists, doArchive will not do
174174+// anything. In all cases, the caller should be examining the *ArchiveRequest
175175+// being returned for completion, as it may be different than the one they passed
176176+// in.
171177func doArchive(ctx context.Context, r *ArchiveRequest) (*repo_model.RepoArchiver, error) {
172172- txCtx, committer, err := db.TxContext(ctx)
173173- if err != nil {
174174- return nil, err
175175- }
176176- defer committer.Close()
177177- ctx, _, finished := process.GetManager().AddContext(txCtx, fmt.Sprintf("ArchiveRequest[%d]: %s", r.RepoID, r.GetArchiveName()))
178178+ ctx, _, finished := process.GetManager().AddContext(ctx, fmt.Sprintf("ArchiveRequest[%d]: %s", r.RepoID, r.GetArchiveName()))
178179 defer finished()
179180180181 archiver, err := repo_model.GetRepoArchiver(ctx, r.RepoID, r.Type, r.CommitID)
···209210 return nil, err
210211 }
211212 }
212212- return archiver, committer.Commit()
213213+ return archiver, nil
213214 }
214215215216 if !errors.Is(err, os.ErrNotExist) {
···278279 }
279280 }
280281281281- return archiver, committer.Commit()
282282-}
283283-284284-// ArchiveRepository satisfies the ArchiveRequest being passed in. Processing
285285-// will occur in a separate goroutine, as this phase may take a while to
286286-// complete. If the archive already exists, ArchiveRepository will not do
287287-// anything. In all cases, the caller should be examining the *ArchiveRequest
288288-// being returned for completion, as it may be different than the one they passed
289289-// in.
290290-func ArchiveRepository(ctx context.Context, request *ArchiveRequest) (*repo_model.RepoArchiver, error) {
291291- return doArchive(ctx, request)
282282+ return archiver, nil
292283}
293284294285var archiverQueue *queue.WorkerPoolQueue[*ArchiveRequest]
···298289 handler := func(items ...*ArchiveRequest) []*ArchiveRequest {
299290 for _, archiveReq := range items {
300291 log.Trace("ArchiverData Process: %#v", archiveReq)
301301- if _, err := doArchive(ctx, archiveReq); err != nil {
292292+ if archiver, err := doArchive(ctx, archiveReq); err != nil {
302293 log.Error("Archive %v failed: %v", archiveReq, err)
294294+ } else {
295295+ log.Trace("ArchiverData Success: %#v", archiver)
303296 }
304297 }
305298 return nil
+6-6
services/repository/archiver/archiver_test.go
···8181 inFlight[1] = tgzReq
8282 inFlight[2] = secondReq
83838484- ArchiveRepository(db.DefaultContext, zipReq)
8585- ArchiveRepository(db.DefaultContext, tgzReq)
8686- ArchiveRepository(db.DefaultContext, secondReq)
8484+ doArchive(db.DefaultContext, zipReq)
8585+ doArchive(db.DefaultContext, tgzReq)
8686+ doArchive(db.DefaultContext, secondReq)
87878888 // Make sure sending an unprocessed request through doesn't affect the queue
8989 // count.
9090- ArchiveRepository(db.DefaultContext, zipReq)
9090+ doArchive(db.DefaultContext, zipReq)
91919292 // Sleep two seconds to make sure the queue doesn't change.
9393 time.Sleep(2 * time.Second)
···102102 // We still have the other three stalled at completion, waiting to remove
103103 // from archiveInProgress. Try to submit this new one before its
104104 // predecessor has cleared out of the queue.
105105- ArchiveRepository(db.DefaultContext, zipReq2)
105105+ doArchive(db.DefaultContext, zipReq2)
106106107107 // Now we'll submit a request and TimedWaitForCompletion twice, before and
108108 // after we release it. We should trigger both the timeout and non-timeout
···110110 timedReq, err := NewRequest(ctx, ctx.Repo.Repository.ID, ctx.Repo.GitRepo, secondCommit+".tar.gz")
111111 require.NoError(t, err)
112112 assert.NotNil(t, timedReq)
113113- ArchiveRepository(db.DefaultContext, timedReq)
113113+ doArchive(db.DefaultContext, timedReq)
114114115115 zipReq2, err = NewRequest(ctx, ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit+".zip")
116116 require.NoError(t, err)