File tree 2 files changed +32
-3
lines changed
2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -1781,6 +1781,12 @@ func UpdateRepository(repo *Repository, visibilityChanged bool) (err error) {
1781
1781
return sess .Commit ()
1782
1782
}
1783
1783
1784
+ // UpdateRepositoryStatus updates a repository's status
1785
+ func UpdateRepositoryStatus (repoID int64 , status RepositoryStatus ) error {
1786
+ _ , err := x .Exec ("UPDATE repository SET status = ? WHERE id = ?" , status , repoID )
1787
+ return err
1788
+ }
1789
+
1784
1790
// UpdateRepositoryUpdatedTime updates a repository's updated time
1785
1791
func UpdateRepositoryUpdatedTime (repoID int64 , updateTime time.Time ) error {
1786
1792
_ , err := x .Exec ("UPDATE repository SET updated_unix = ? WHERE id = ?" , updateTime .Unix (), repoID )
Original file line number Diff line number Diff line change 6
6
package repo
7
7
8
8
import (
9
+ "bytes"
10
+ "errors"
9
11
"fmt"
10
12
"net/http"
11
13
"net/url"
@@ -431,10 +433,31 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
431
433
opts .Releases = false
432
434
}
433
435
434
- repo , err := migrations .MigrateRepository (ctx .User , ctxUser .Name , opts )
435
- if err == nil {
436
- notification .NotifyCreateRepository (ctx .User , ctxUser , repo )
436
+ var repo * models.Repository
437
+ defer func () {
438
+ if e := recover (); e != nil {
439
+ var buf bytes.Buffer
440
+ fmt .Fprintf (& buf , "Handler crashed with error: %v" , log .Stack (2 ))
441
+ err = errors .New (buf .String ())
442
+ }
443
+
444
+ if err == nil {
445
+ repo .Status = models .RepositoryReady
446
+ if err := models .UpdateRepositoryStatus (repo .ID , repo .Status ); err == nil {
447
+ notification .NotifyMigrateRepository (ctx .User , ctxUser , repo )
448
+ return
449
+ }
450
+ }
437
451
452
+ if repo != nil {
453
+ if errDelete := models .DeleteRepository (ctx .User , ctxUser .ID , repo .ID ); errDelete != nil {
454
+ log .Error ("DeleteRepository: %v" , errDelete )
455
+ }
456
+ }
457
+ }()
458
+
459
+ repo , err = migrations .MigrateRepository (ctx .User , ctxUser .Name , opts )
460
+ if err == nil {
438
461
log .Trace ("Repository migrated: %s/%s" , ctxUser .Name , form .RepoName )
439
462
ctx .JSON (201 , repo .APIFormat (models .AccessModeAdmin ))
440
463
return
You can’t perform that action at this time.
0 commit comments