diff options
Diffstat (limited to 'models/repo_transfer.go')
-rw-r--r-- | models/repo_transfer.go | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/models/repo_transfer.go b/models/repo_transfer.go index 09b6290293..2ede0fbbe7 100644 --- a/models/repo_transfer.go +++ b/models/repo_transfer.go @@ -8,6 +8,7 @@ import ( "fmt" "os" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" @@ -28,6 +29,10 @@ type RepoTransfer struct { UpdatedUnix timeutil.TimeStamp `xorm:"INDEX NOT NULL updated"` } +func init() { + db.RegisterModel(new(RepoTransfer)) +} + // LoadAttributes fetches the transfer recipient from the database func (r *RepoTransfer) LoadAttributes() error { if r.Recipient == nil { @@ -93,7 +98,7 @@ func (r *RepoTransfer) CanUserAcceptTransfer(u *User) bool { func GetPendingRepositoryTransfer(repo *Repository) (*RepoTransfer, error) { transfer := new(RepoTransfer) - has, err := x.Where("repo_id = ? ", repo.ID).Get(transfer) + has, err := db.DefaultContext().Engine().Where("repo_id = ? ", repo.ID).Get(transfer) if err != nil { return nil, err } @@ -105,7 +110,7 @@ func GetPendingRepositoryTransfer(repo *Repository) (*RepoTransfer, error) { return transfer, nil } -func deleteRepositoryTransfer(e Engine, repoID int64) error { +func deleteRepositoryTransfer(e db.Engine, repoID int64) error { _, err := e.Where("repo_id = ?", repoID).Delete(&RepoTransfer{}) return err } @@ -113,7 +118,7 @@ func deleteRepositoryTransfer(e Engine, repoID int64) error { // CancelRepositoryTransfer marks the repository as ready and remove pending transfer entry, // thus cancel the transfer process. func CancelRepositoryTransfer(repo *Repository) error { - sess := x.NewSession() + sess := db.DefaultContext().NewSession() defer sess.Close() if err := sess.Begin(); err != nil { return err @@ -145,7 +150,7 @@ func TestRepositoryReadyForTransfer(status RepositoryStatus) error { // CreatePendingRepositoryTransfer transfer a repo from one owner to a new one. // it marks the repository transfer as "pending" func CreatePendingRepositoryTransfer(doer, newOwner *User, repoID int64, teams []*Team) error { - sess := x.NewSession() + sess := db.DefaultContext().NewSession() defer sess.Close() if err := sess.Begin(); err != nil { return err @@ -227,7 +232,7 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) (err e } }() - sess := x.NewSession() + sess := db.DefaultContext().NewSession() defer sess.Close() if err := sess.Begin(); err != nil { return fmt.Errorf("sess.Begin: %v", err) |