From 79aeb92e0c4614fafad23cefc710ca2c1087379d Mon Sep 17 00:00:00 2001 From: Lukas Date: Fri, 20 Sep 2024 22:39:22 +0200 Subject: [PATCH] Set repo user to repairing user when old user is missing (#4128) --- server/api/repo.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/api/repo.go b/server/api/repo.go index 84b9b8002..b96eeaae6 100644 --- a/server/api/repo.go +++ b/server/api/repo.go @@ -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) }