summaryrefslogtreecommitdiffstats
path: root/models/access.go
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-04-04 18:55:17 -0400
committerUnknown <joe2010xtmf@163.com>2014-04-04 18:55:17 -0400
commite41ab839c7dbbdffc60a4e02775f24add9d126d9 (patch)
treeac450cf0e38a6fa4819ea4701a79e7719dbfe77d /models/access.go
parenteb803ec5eb3a7e66a107873ce6ee584b8c77b131 (diff)
downloadgitea-e41ab839c7dbbdffc60a4e02775f24add9d126d9.tar.gz
gitea-e41ab839c7dbbdffc60a4e02775f24add9d126d9.zip
Use session for rolling back
Diffstat (limited to 'models/access.go')
-rw-r--r--models/access.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/models/access.go b/models/access.go
index 83261575e6..2c0900151f 100644
--- a/models/access.go
+++ b/models/access.go
@@ -7,6 +7,8 @@ package models
import (
"strings"
"time"
+
+ "github.com/lunny/xorm"
)
// Access types.
@@ -40,6 +42,15 @@ func UpdateAccess(access *Access) error {
return err
}
+// UpdateAccess updates access information with session for rolling back.
+func UpdateAccessWithSession(sess *xorm.Session, access *Access) error {
+ if _, err := sess.Id(access.Id).Update(access); err != nil {
+ sess.Rollback()
+ return err
+ }
+ return nil
+}
+
// HasAccess returns true if someone can read or write to given repository.
func HasAccess(userName, repoName string, mode int) (bool, error) {
return orm.Get(&Access{