diff --git a/files/routes/posts.py b/files/routes/posts.py index 44635359b..b6cd22c53 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -95,6 +95,8 @@ def post_id(pid, v, anything=None, sub=None): p.views += 1 g.db.add(p) + try: g.db.flush() + except: g.db.rollback() if p.new: defaultsortingcomments = 'new' elif v: defaultsortingcomments = v.defaultsortingcomments diff --git a/files/routes/votes.py b/files/routes/votes.py index f037efa72..f6e1ea00b 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -138,6 +138,9 @@ def vote_post_comment(target_id, new, v, cls, vote_cls): ) g.db.add(vote) + try: g.db.flush() + except: g.db.rollback() + # this is hacky but it works, we should probably do better later def get_vote_count(dir, real_instead_of_dir): votes = g.db.query(vote_cls)