From bab6221882018ca2023e2341291578d0121f174f Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 19 Aug 2015 19:36:49 +0200 Subject: [PATCH] [IMP] runbot: drop all db with build prefix on cleanup --- runbot/runbot.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/runbot/runbot.py b/runbot/runbot.py index 651a07f5..df528365 100644 --- a/runbot/runbot.py +++ b/runbot/runbot.py @@ -1029,8 +1029,15 @@ class runbot_build(osv.osv): def cleanup(self, cr, uid, ids, context=None): for build in self.browse(cr, uid, ids, context=context): - self.pg_dropdb(cr, uid, "%s-base" % build.dest) - self.pg_dropdb(cr, uid, "%s-all" % build.dest) + cr.execute(""" + SELECT datname + FROM pg_database + WHERE pg_get_userbyid(datdba) = current_user + AND datname LIKE %s + """, [build.dest + '%']) + for db, in cr.fetchall(): + self.pg_dropdb(cr, uid, db) + if os.path.isdir(build.path()) and build.result != 'killed': shutil.rmtree(build.path())