mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Rename almost all Ctx functions (#22071)
This commit is contained in:
@@ -298,44 +298,32 @@ func changeProjectStatus(ctx context.Context, p *Project, isClosed bool) error {
|
||||
return updateRepositoryProjectCount(ctx, p.RepoID)
|
||||
}
|
||||
|
||||
// DeleteProjectByID deletes a project from a repository.
|
||||
func DeleteProjectByID(id int64) error {
|
||||
ctx, committer, err := db.TxContext(db.DefaultContext)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer committer.Close()
|
||||
|
||||
if err := DeleteProjectByIDCtx(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return committer.Commit()
|
||||
}
|
||||
|
||||
// DeleteProjectByIDCtx deletes a project from a repository.
|
||||
func DeleteProjectByIDCtx(ctx context.Context, id int64) error {
|
||||
p, err := GetProjectByID(ctx, id)
|
||||
if err != nil {
|
||||
if IsErrProjectNotExist(err) {
|
||||
return nil
|
||||
// DeleteProjectByID deletes a project from a repository. if it's not in a database
|
||||
// transaction, it will start a new database transaction
|
||||
func DeleteProjectByID(ctx context.Context, id int64) error {
|
||||
return db.AutoTx(ctx, func(ctx context.Context) error {
|
||||
p, err := GetProjectByID(ctx, id)
|
||||
if err != nil {
|
||||
if IsErrProjectNotExist(err) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
if err := deleteProjectIssuesByProjectID(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := deleteProjectIssuesByProjectID(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := deleteBoardByProjectID(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := deleteBoardByProjectID(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err = db.GetEngine(ctx).ID(p.ID).Delete(new(Project)); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err = db.GetEngine(ctx).ID(p.ID).Delete(new(Project)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return updateRepositoryProjectCount(ctx, p.RepoID)
|
||||
return updateRepositoryProjectCount(ctx, p.RepoID)
|
||||
})
|
||||
}
|
||||
|
||||
func DeleteProjectByRepoID(ctx context.Context, repoID int64) error {
|
||||
|
Reference in New Issue
Block a user