mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-02-16 19:35:14 +00:00
ignore some errors on repairAllRepos (#2792)
close #2791 Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
This commit is contained in:
parent
c6ce23e933
commit
4974d4cffe
1 changed files with 17 additions and 6 deletions
|
@ -412,8 +412,10 @@ func DeleteRepo(c *gin.Context) {
|
|||
// @Param repo_id path int true "the repository id"
|
||||
func RepairRepo(c *gin.Context) {
|
||||
repo := session.Repo(c)
|
||||
repairRepo(c, repo, true)
|
||||
|
||||
repairRepo(c, repo, true, false)
|
||||
if c.Writer.Written() {
|
||||
return
|
||||
}
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
|
@ -544,7 +546,7 @@ func RepairAllRepos(c *gin.Context) {
|
|||
}
|
||||
|
||||
for _, r := range repos {
|
||||
repairRepo(c, r, false)
|
||||
repairRepo(c, r, false, true)
|
||||
if c.Writer.Written() {
|
||||
return
|
||||
}
|
||||
|
@ -553,13 +555,20 @@ func RepairAllRepos(c *gin.Context) {
|
|||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
func repairRepo(c *gin.Context, repo *model.Repo, withPerms bool) {
|
||||
func repairRepo(c *gin.Context, repo *model.Repo, withPerms, skipOnErr bool) {
|
||||
forge := server.Config.Services.Forge
|
||||
_store := store.FromContext(c)
|
||||
|
||||
user, err := _store.GetUser(repo.UserID)
|
||||
if err != nil {
|
||||
handleDbError(c, err)
|
||||
if errors.Is(err, types.RecordNotExist) {
|
||||
if !skipOnErr {
|
||||
c.AbortWithStatus(http.StatusNotFound)
|
||||
}
|
||||
log.Error().Err(err).Msgf("could not get user on repo repair")
|
||||
} else {
|
||||
_ = c.AbortWithError(http.StatusInternalServerError, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -582,7 +591,9 @@ func repairRepo(c *gin.Context, repo *model.Repo, withPerms bool) {
|
|||
from, err := forge.Repo(c, user, repo.ForgeRemoteID, repo.Owner, repo.Name)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msgf("get repo '%s/%s' from forge", repo.Owner, repo.Name)
|
||||
c.AbortWithStatus(http.StatusInternalServerError)
|
||||
if !skipOnErr {
|
||||
c.AbortWithStatus(http.StatusInternalServerError)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue