From 71e4f767ee596a9359853a8bc85b7644faf710dc Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Mon, 1 Jun 2009 19:29:14 +0200 Subject: [PATCH] entropy.db: when loading LocalRepository and it fails, make sure to close the fd --- libraries/entropy/db.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/libraries/entropy/db.py b/libraries/entropy/db.py index b8af650b0..5ba3df225 100644 --- a/libraries/entropy/db.py +++ b/libraries/entropy/db.py @@ -437,14 +437,19 @@ class LocalRepository: self.cursor = self.connection.cursor() if not self.skipChecks: - if os.access(self.dbFile, os.W_OK) and \ - self.doesTableExist('baseinfo') and \ - self.doesTableExist('extrainfo'): + try: + if os.access(self.dbFile, os.W_OK) and \ + self.doesTableExist('baseinfo') and \ + self.doesTableExist('extrainfo'): - if self.entropyTools.islive() and etpConst['systemroot']: - self.databaseStructureUpdates() - else: - self.databaseStructureUpdates() + if self.entropyTools.islive() and etpConst['systemroot']: + self.databaseStructureUpdates() + else: + self.databaseStructureUpdates() + except self.dbapi2.Error: + self.cursor.close() + self.connection.close() + raise # now we can set this to False self.dbclosed = False @@ -1382,14 +1387,14 @@ class LocalRepository: with self.__write_mutex: self.cursor.execute(""" - INSERT into baseinfo VALUES (%s,?,?,?,?,?,?,?,?,?,?,?)""" % ( + INSERT INTO baseinfo VALUES (%s,?,?,?,?,?,?,?,?,?,?,?)""" % ( myidpackage_string,), mybaseinfo_data) if idpackage == None: idpackage = self.cursor.lastrowid # extrainfo self.cursor.execute( - 'INSERT into extrainfo VALUES (?,?,?,?,?,?,?,?)', + 'INSERT INTO extrainfo VALUES (?,?,?,?,?,?,?,?)', ( idpackage, etpData['description'], etpData['homepage'],