From 1375d2a4bec927bb48cee9691fcee218581a69c6 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Mar 11 2019 17:44:57 +0000 Subject: [frontend] don't forget to commit in 'manage.py alter_chroot' This happened previously upon 'if action != "eol": continue' condition, where we forgot to session.commit() and thus automatic rollback happened. Fixes: #563 --- diff --git a/frontend/coprs_frontend/commands/alter_chroot.py b/frontend/coprs_frontend/commands/alter_chroot.py index 53e6e2b..d081a26 100644 --- a/frontend/coprs_frontend/commands/alter_chroot.py +++ b/frontend/coprs_frontend/commands/alter_chroot.py @@ -1,6 +1,6 @@ import datetime from flask_script import Option -from coprs import db +from coprs import db_session_scope from coprs import app from coprs import exceptions from coprs.logic import coprs_logic @@ -15,19 +15,19 @@ class AlterChrootCommand(ChrootCommand): activate = (action == "activate") for chroot_name in chroot_names: try: - mock_chroot = coprs_logic.MockChrootsLogic.edit_by_name( - chroot_name, activate) + with db_session_scope(): + mock_chroot = coprs_logic.MockChrootsLogic.edit_by_name( + chroot_name, activate) - if action != "eol": - continue + if action != "eol": + continue - for copr_chroot in mock_chroot.copr_chroots: - delete_after_days = app.config["DELETE_EOL_CHROOTS_AFTER"] + 1 - delete_after_timestamp = datetime.datetime.now() + datetime.timedelta(delete_after_days) - # Workarounding an auth here - coprs_logic.CoprChrootsLogic.update_chroot(copr_chroot.copr.user, copr_chroot, - delete_after=delete_after_timestamp) - db.session.commit() + for copr_chroot in mock_chroot.copr_chroots: + delete_after_days = app.config["DELETE_EOL_CHROOTS_AFTER"] + 1 + delete_after_timestamp = datetime.datetime.now() + datetime.timedelta(delete_after_days) + # Workarounding an auth here + coprs_logic.CoprChrootsLogic.update_chroot(copr_chroot.copr.user, copr_chroot, + delete_after=delete_after_timestamp) except exceptions.MalformedArgumentException: self.print_invalid_format(chroot_name) except exceptions.NotFoundException: