fix: avoid nil panic and refactor some trivial problems (#39251)

This commit is contained in:
wxiaoguang
2026-09-06 09:49:27 +00:00
committed by GitHub
parent 87d5497da0
commit 3176f37887
16 changed files with 91 additions and 126 deletions
+1 -2
View File
@@ -5,7 +5,6 @@ package admin
import (
"net/http"
"net/url"
"time"
"gitea.dev/models/db"
@@ -93,7 +92,7 @@ func DeletePackageVersion(ctx *context.Context) {
}
ctx.Flash.Success(ctx.Tr("packages.settings.delete.version.success"))
ctx.JSONRedirect(setting.AppSubURL + "/-/admin/packages?page=" + url.QueryEscape(ctx.FormString("page")) + "&q=" + url.QueryEscape(ctx.FormString("q")) + "&type=" + url.QueryEscape(ctx.FormString("type")))
ctx.JSONRedirect("")
}
func CleanupExpiredData(ctx *context.Context) {
+1 -5
View File
@@ -47,10 +47,6 @@ func DeleteRepo(ctx *context.Context) {
return
}
if ctx.Repo != nil && ctx.Repo.GitRepo != nil && ctx.Repo.Repository != nil && ctx.Repo.Repository.ID == repo.ID {
ctx.Repo.GitRepo.Close()
}
if err := repo_service.DeleteRepository(ctx, ctx.Doer, repo, true); err != nil {
ctx.ServerError("DeleteRepository", err)
return
@@ -58,7 +54,7 @@ func DeleteRepo(ctx *context.Context) {
log.Trace("Repository deleted: %s", repo.FullName())
ctx.Flash.Success(ctx.Tr("repo.settings.deletion_success"))
ctx.JSONRedirect(setting.AppSubURL + "/-/admin/repos?page=" + url.QueryEscape(ctx.FormString("page")) + "&sort=" + url.QueryEscape(ctx.FormString("sort")))
ctx.JSONRedirect("")
}
// UnadoptedRepos lists the unadopted repositories