Fix database is locked problem for sqlite databases

fix-sqlite
Jonas Franz 6 years ago committed by Jonas Franz
parent 92b6438b55
commit 64e87b3779
No known key found for this signature in database
GPG Key ID: C00A5F91E41AB585
  1. 10
      cmd/migrate.go

@ -94,8 +94,13 @@ func migrate(c context.Context, gc *github.Client, m *migrations.Migratory, user
//bar := p.AddBar(int64(len(issues)))
for _, gi := range allIssues {
fmt.Printf("Migrating #%d...\n", *gi.Number)
retry:
issue, err := m.Issue(gi)
if err != nil {
if strings.Contains(err.Error(), "database table is locked") {
fmt.Printf("Retring #%d since db table is locked\n", *gi.Number)
goto retry
}
return fmt.Errorf("migrating issue[id: %d]: %v", *gi.ID, err)
}
comments, _, err := gc.Issues.ListComments(c, username, repo, gi.GetNumber(), nil)
@ -104,7 +109,12 @@ func migrate(c context.Context, gc *github.Client, m *migrations.Migratory, user
}
for _, gc := range comments {
fmt.Printf("-> %d...", gc.ID)
retry_comment:
if _, err := m.IssueComment(issue, gc); err != nil {
if strings.Contains(err.Error(), "database table is locked") {
fmt.Printf("Retring comment #%d since db table is locked\n", gc.GetID())
goto retry_comment
}
return fmt.Errorf("migrating issue comment [issue: %d, comment: %d]: %v", *gi.ID, gc.ID, err)
}
fmt.Print("Done!\n")

Loading…
Cancel
Save