diff --git a/files/routes/comments.py b/files/routes/comments.py index cdea14da2..7deb489b9 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -901,9 +901,6 @@ def save_comment(cid, v): g.db.add(new_save) - try: g.db.flush() - except: g.db.rollback() - g.db.commit() return {"message": "Comment saved!"} diff --git a/files/routes/errors.py b/files/routes/errors.py index 190cdfdad..664f73c8c 100644 --- a/files/routes/errors.py +++ b/files/routes/errors.py @@ -102,10 +102,7 @@ def error_451(e, v): @app.errorhandler(500) @auth_desired def error_500(e, v): - try: - g.db.rollback() - except AttributeError: - pass + g.db.rollback() if request.headers.get("Authorization"): return {"error": "500 Internal Server Error"}, 500 else: return render_template('errors/500.html', v=v), 500 diff --git a/files/routes/login.py b/files/routes/login.py index bf221851f..4e5a0d9e5 100644 --- a/files/routes/login.py +++ b/files/routes/login.py @@ -47,37 +47,17 @@ def check_for_alts(current_id): otheralts = g.db.query(Alt).filter(or_(Alt.user1 == past_id, Alt.user2 == past_id, Alt.user1 == current_id, Alt.user2 == current_id)).all() for a in otheralts: - try: - new_alt = Alt(user1=a.user1, user2=past_id) - g.db.add(new_alt) - g.db.flush() - except Exception as e: - g.db.rollback() - continue + new_alt = Alt(user1=a.user1, user2=past_id) + g.db.add(new_alt) for a in otheralts: - try: - new_alt = Alt(user1=a.user1, user2=current_id) - g.db.add(new_alt) - g.db.flush() - except Exception as e: - g.db.rollback() - continue + new_alt = Alt(user1=a.user1, user2=current_id) + g.db.add(new_alt) for a in otheralts: - try: - new_alt = Alt(user1=a.user2, user2=past_id) - g.db.add(new_alt) - g.db.flush() - except Exception as e: - g.db.rollback() - continue + new_alt = Alt(user1=a.user2, user2=past_id) + g.db.add(new_alt) for a in otheralts: - try: - new_alt = Alt(user1=a.user2, user2=current_id) - g.db.add(new_alt) - g.db.flush() - except Exception as e: - g.db.rollback() - continue + new_alt = Alt(user1=a.user2, user2=current_id) + g.db.add(new_alt) # login post procedure diff --git a/files/routes/settings.py b/files/routes/settings.py index 96744e18c..3bf55d0b2 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -111,7 +111,6 @@ def settings_profile_post(v): #check file size if request.content_length > 16 * 1024 * 1024: - g.db.rollback() abort(413) file = request.files['file'] @@ -514,7 +513,6 @@ def settings_log_out_others(v): def settings_images_profile(v): if request.content_length > 16 * 1024 * 1024: - g.db.rollback() abort(413) if request.headers.get("cf-ipcountry") == "T1": return "Image uploads are not allowed through TOR.", 403 @@ -542,7 +540,6 @@ def settings_images_profile(v): @validate_formkey def settings_images_banner(v): if request.content_length > 16 * 1024 * 1024: - g.db.rollback() abort(413) if request.headers.get("cf-ipcountry") == "T1": return "Image uploads are not allowed through TOR.", 403 diff --git a/files/routes/votes.py b/files/routes/votes.py index 498155e90..3be315e7a 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -96,8 +96,6 @@ def api_vote_post(post_id, new, v): ) g.db.add(vote) - try: g.db.flush() - except: g.db.rollback() post.upvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=1).count() post.downvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=-1).count() g.db.add(post) @@ -151,8 +149,6 @@ def api_vote_comment(comment_id, new, v): g.db.add(vote) - try: g.db.flush() - except: g.db.rollback() comment.upvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=1).count() comment.downvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=-1).count() g.db.add(comment)