diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2014-08-15 16:23:15 -0500 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2014-08-15 16:30:59 -0500 |
commit | cbc5f9500cadc5f65eeebb1558cd9947655b1b3a (patch) | |
tree | ebe3756698663663f7d59d4fd04ce179381b4fe3 | |
parent | 8cfa4071bf8fef5724413e09677a38f57871c023 (diff) | |
download | mediagoblin-cbc5f9500cadc5f65eeebb1558cd9947655b1b3a.tar.lz mediagoblin-cbc5f9500cadc5f65eeebb1558cd9947655b1b3a.tar.xz mediagoblin-cbc5f9500cadc5f65eeebb1558cd9947655b1b3a.zip |
Always remove the session when running check_db_up_to_date()
This commit sponsored by Francois Marier. Thank you!
-rw-r--r-- | mediagoblin/db/util.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/mediagoblin/db/util.py b/mediagoblin/db/util.py index aba9c59c..515fd6cd 100644 --- a/mediagoblin/db/util.py +++ b/mediagoblin/db/util.py @@ -76,11 +76,16 @@ def check_db_up_to_date(): dbdatas = gather_database_data(mgg.global_config.get('plugins', {}).keys()) for dbdata in dbdatas: - migration_manager = dbdata.make_migration_manager(Session()) - if migration_manager.database_current_migration is None or \ - migration_manager.migrations_to_run(): - sys.exit("Your database is not up to date. Please run " - "'gmg dbupdate' before starting MediaGoblin.") + session = Session() + try: + migration_manager = dbdata.make_migration_manager(session) + if migration_manager.database_current_migration is None or \ + migration_manager.migrations_to_run(): + sys.exit("Your database is not up to date. Please run " + "'gmg dbupdate' before starting MediaGoblin.") + finally: + Session.rollback() + Session.remove() if __name__ == '__main__': |