Skip to content

Commit f20d2f4

Browse files
committed
fix
1 parent bf8ecf7 commit f20d2f4

File tree

5 files changed

+33
-28
lines changed

5 files changed

+33
-28
lines changed

models/issues/issue_search.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ func applySubscribedCondition(sess *xorm.Session, subscriberID int64) {
476476
),
477477
builder.Eq{"issue.poster_id": subscriberID},
478478
builder.In("issue.repo_id", builder.
479-
Select("id").
479+
Select("repo_id").
480480
From("watch").
481481
Where(builder.And(builder.Eq{"user_id": subscriberID},
482482
builder.In("mode", repo_model.WatchModeNormal, repo_model.WatchModeAuto))),

models/issues/issue_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ func TestIssues(t *testing.T) {
197197
},
198198
[]int64{2},
199199
},
200+
{
201+
issues_model.IssuesOptions{
202+
SubscriberID: 11,
203+
},
204+
[]int64{11, 5, 9, 8, 3, 2, 1},
205+
},
200206
} {
201207
issues, err := issues_model.Issues(t.Context(), &test.Opts)
202208
assert.NoError(t, err)

modules/web/routing/logger.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ func logPrinter(logger log.Logger) func(trigger Event, record *requestRecord) {
104104
}
105105
logf := logInfo
106106
// lower the log level for some specific requests, in most cases these logs are not useful
107-
if strings.HasPrefix(req.RequestURI, "/assets/") /* static assets */ ||
107+
if 0 < status && status < 400 &&
108+
strings.HasPrefix(req.RequestURI, "/assets/") /* static assets */ ||
108109
req.RequestURI == "/user/events" /* Server-Sent Events (SSE) handler */ ||
109110
req.RequestURI == "/api/actions/runner.v1.RunnerService/FetchTask" /* Actions Runner polling */ {
110111
logf = logTrace

routers/api/v1/repo/migrate.go

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
package repo
55

66
import (
7-
"bytes"
7+
gocontext "context"
88
"errors"
99
"fmt"
1010
"net/http"
@@ -173,7 +173,7 @@ func Migrate(ctx *context.APIContext) {
173173
opts.AWSSecretAccessKey = form.AWSSecretAccessKey
174174
}
175175

176-
repo, err := repo_service.CreateRepositoryDirectly(ctx, ctx.Doer, repoOwner, repo_service.CreateRepoOptions{
176+
createdRepo, err := repo_service.CreateRepositoryDirectly(ctx, ctx.Doer, repoOwner, repo_service.CreateRepoOptions{
177177
Name: opts.RepoName,
178178
Description: opts.Description,
179179
OriginalURL: form.CloneAddr,
@@ -187,35 +187,33 @@ func Migrate(ctx *context.APIContext) {
187187
return
188188
}
189189

190-
opts.MigrateToRepoID = repo.ID
190+
opts.MigrateToRepoID = createdRepo.ID
191191

192-
defer func() {
193-
if e := recover(); e != nil {
194-
var buf bytes.Buffer
195-
fmt.Fprintf(&buf, "Handler crashed with error: %v", log.Stack(2))
196-
197-
err = errors.New(buf.String())
198-
}
199-
200-
if err == nil {
201-
notify_service.MigrateRepository(ctx, ctx.Doer, repoOwner, repo)
202-
return
203-
}
204-
205-
if repo != nil {
206-
if errDelete := repo_service.DeleteRepositoryDirectly(ctx, repo.ID); errDelete != nil {
207-
log.Error("DeleteRepository: %v", errDelete)
192+
doLongTimeMigrate := func(ctx gocontext.Context, doer *user_model.User) (migratedRepo *repo_model.Repository, retErr error) {
193+
defer func() {
194+
if e := recover(); e != nil {
195+
log.Error("Migration panic: %v\n%s", e, log.Stack(2))
196+
if errDelete := repo_service.DeleteRepositoryDirectly(ctx, createdRepo.ID); errDelete != nil {
197+
log.Error("Unable to delete repo after migration panic: %v", errDelete)
198+
}
199+
retErr = errors.New("migration panic")
208200
}
201+
}()
202+
migratedRepo, err := migrations.MigrateRepository(graceful.GetManager().HammerContext(), doer, repoOwner.Name, opts, nil)
203+
if err != nil {
204+
return nil, err
209205
}
210-
}()
206+
notify_service.MigrateRepository(ctx, doer, repoOwner, migratedRepo)
207+
return migratedRepo, nil
208+
}
211209

212-
if repo, err = migrations.MigrateRepository(graceful.GetManager().HammerContext(), ctx.Doer, repoOwner.Name, opts, nil); err != nil {
210+
// don't cancel the migration even if the client goes away
211+
migratedRepo, err := doLongTimeMigrate(graceful.GetManager().ShutdownContext(), ctx.Doer)
212+
if err != nil {
213213
handleMigrateError(ctx, repoOwner, err)
214214
return
215215
}
216-
217-
log.Trace("Repository migrated: %s/%s", repoOwner.Name, form.RepoName)
218-
ctx.JSON(http.StatusCreated, convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm.AccessModeAdmin}))
216+
ctx.JSON(http.StatusCreated, convert.ToRepo(ctx, migratedRepo, access_model.Permission{AccessMode: perm.AccessModeAdmin}))
219217
}
220218

221219
func handleMigrateError(ctx *context.APIContext, repoOwner *user_model.User, err error) {

templates/mail/repo/release.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
<ul>
3333
{{if not .DisableDownloadSourceArchives}}
3434
<li>
35-
<a href="{{.Release.Repo.Link}}/archive/{{.Release.TagName | PathEscapeSegments}}.zip" rel="nofollow"><strong>{{.locale.Tr "mail.release.download.zip"}}</strong></a>
35+
<a href="{{.Release.Repo.HTMLURL}}/archive/{{.Release.TagName | PathEscapeSegments}}.zip" rel="nofollow"><strong>{{.locale.Tr "mail.release.download.zip"}}</strong></a>
3636
</li>
3737
<li>
38-
<a href="{{.Release.Repo.Link}}/archive/{{.Release.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow"><strong>{{.locale.Tr "mail.release.download.targz"}}</strong></a>
38+
<a href="{{.Release.Repo.HTMLURL}}/archive/{{.Release.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow"><strong>{{.locale.Tr "mail.release.download.targz"}}</strong></a>
3939
</li>
4040
{{end}}
4141
{{if .Release.Attachments}}

0 commit comments

Comments
 (0)