diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-21 23:41:00 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-21 23:41:00 +0800 |
commit | d710af6669654f27f02b69d7ef1ba563e7d58a90 (patch) | |
tree | 9727f468a570106293dc90beb70035180bbb7e8e /models/lfs_lock.go | |
parent | 0add627182388ac63fd04b94cdf912fb87fd0326 (diff) | |
download | gitea-d710af6669654f27f02b69d7ef1ba563e7d58a90.tar.gz gitea-d710af6669654f27f02b69d7ef1ba563e7d58a90.zip |
Remove NewSession method from db.Engine interface (#17577)
* Remove NewSession method from db.Engine interface
* Fix bug
* Some improvements
* Fix bug
* Fix test
* Use XXXBean instead of XXXExample
Diffstat (limited to 'models/lfs_lock.go')
-rw-r--r-- | models/lfs_lock.go | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/models/lfs_lock.go b/models/lfs_lock.go index 247444a66d..943699290f 100644 --- a/models/lfs_lock.go +++ b/models/lfs_lock.go @@ -105,18 +105,16 @@ func GetLFSLockByID(id int64) (*LFSLock, error) { // GetLFSLockByRepoID returns a list of locks of repository. func GetLFSLockByRepoID(repoID int64, page, pageSize int) ([]*LFSLock, error) { - sess := db.NewSession(db.DefaultContext) - defer sess.Close() - + e := db.GetEngine(db.DefaultContext) if page >= 0 && pageSize > 0 { start := 0 if page > 0 { start = (page - 1) * pageSize } - sess.Limit(pageSize, start) + e.Limit(pageSize, start) } lfsLocks := make([]*LFSLock, 0, pageSize) - return lfsLocks, sess.Find(&lfsLocks, &LFSLock{RepoID: repoID}) + return lfsLocks, e.Find(&lfsLocks, &LFSLock{RepoID: repoID}) } // CountLFSLockByRepoID returns a count of all LFSLocks associated with a repository. |