entropy.db: when loading LocalRepository and it fails, make sure to close the fd

This commit is contained in:
Fabio Erculiani
2009-06-01 19:29:14 +02:00
parent 49a922498d
commit 71e4f767ee
+14 -9
View File
@@ -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'],