Skip to content

Commit 6a5e1ad

Browse files
Migration failure during reaction migration from gitea (go-gitea#13344)
* Migrating reactions is just not that important A failure during migrating reactions should not cause failure of migration. Signed-off-by: Andrew Thornton <[email protected]> * When checking issue reactions check the correct permission Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent adfe13f commit 6a5e1ad

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

modules/migrations/gitea_downloader.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"strings"
1515
"time"
1616

17+
"code.gitea.io/gitea/models"
1718
"code.gitea.io/gitea/modules/log"
1819
"code.gitea.io/gitea/modules/migrations/base"
1920
"code.gitea.io/gitea/modules/structs"
@@ -395,7 +396,11 @@ func (g *GiteaDownloader) GetIssues(page, perPage int) ([]*base.Issue, bool, err
395396

396397
reactions, err := g.getIssueReactions(issue.Index)
397398
if err != nil {
398-
return nil, false, fmt.Errorf("error while loading reactions for issue #%d. Error: %v", issue.Index, err)
399+
log.Warn("Unable to load reactions during migrating issue #%d to %s/%s. Error: %v", issue.Index, g.repoOwner, g.repoName, err)
400+
if err2 := models.CreateRepositoryNotice(
401+
fmt.Sprintf("Unable to load reactions during migrating issue #%d to %s/%s. Error: %v", issue.Index, g.repoOwner, g.repoName, err)); err2 != nil {
402+
log.Error("create repository notice failed: ", err2)
403+
}
399404
}
400405

401406
var assignees []string
@@ -534,7 +539,11 @@ func (g *GiteaDownloader) GetPullRequests(page, perPage int) ([]*base.PullReques
534539

535540
reactions, err := g.getIssueReactions(pr.Index)
536541
if err != nil {
537-
return nil, false, fmt.Errorf("error while loading reactions for pull #%d. Error: %v", pr.Index, err)
542+
log.Warn("Unable to load reactions during migrating pull #%d to %s/%s. Error: %v", pr.Index, g.repoOwner, g.repoName, err)
543+
if err2 := models.CreateRepositoryNotice(
544+
fmt.Sprintf("Unable to load reactions during migrating pull #%d to %s/%s. Error: %v", pr.Index, g.repoOwner, g.repoName, err)); err2 != nil {
545+
log.Error("create repository notice failed: ", err2)
546+
}
538547
}
539548

540549
var assignees []string

modules/migrations/migrate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func MigrateRepository(ctx context.Context, doer *models.User, ownerName string,
6969
}
7070

7171
if err2 := models.CreateRepositoryNotice(fmt.Sprintf("Migrate repository from %s failed: %v", opts.OriginalURL, err)); err2 != nil {
72-
log.Error("create respotiry notice failed: ", err2)
72+
log.Error("create repository notice failed: ", err2)
7373
}
7474
return nil, err
7575
}

routers/api/v1/repo/issue_reaction.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ func GetIssueReactions(ctx *context.APIContext) {
270270
return
271271
}
272272

273-
if !ctx.Repo.CanRead(models.UnitTypeIssues) {
273+
if !ctx.Repo.CanReadIssuesOrPulls(issue.IsPull) {
274274
ctx.Error(http.StatusForbidden, "GetIssueReactions", errors.New("no permission to get reactions"))
275275
return
276276
}

0 commit comments

Comments
 (0)