mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-23 00:46:30 +00:00
Set repo user to repairing user when old user is missing (#4128)
This commit is contained in:
parent
e52dfc92e3
commit
79aeb92e0c
1 changed files with 7 additions and 3 deletions
|
@ -615,10 +615,14 @@ func repairRepo(c *gin.Context, repo *model.Repo, withPerms, skipOnErr bool) {
|
|||
user, err := _store.GetUser(repo.UserID)
|
||||
if err != nil {
|
||||
if errors.Is(err, types.RecordNotExist) {
|
||||
if !skipOnErr {
|
||||
c.AbortWithStatus(http.StatusNotFound)
|
||||
oldUserID := repo.UserID
|
||||
user = session.User(c)
|
||||
repo.UserID = user.ID
|
||||
err = _store.UpdateRepo(repo)
|
||||
if err != nil {
|
||||
_ = c.AbortWithError(http.StatusInternalServerError, err)
|
||||
}
|
||||
log.Error().Err(err).Msg("could not get user on repo repair")
|
||||
log.Debug().Msgf("Could not find repo user with ID %d during repo repair, set to repair request user with ID %d", oldUserID, user.ID)
|
||||
} else {
|
||||
_ = c.AbortWithError(http.StatusInternalServerError, err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue