[entropy.db] improve EntropyRepository.validateDatabase() reliability

This commit is contained in:
Fabio Erculiani
2010-07-14 23:48:39 +02:00
parent c48e3e1a13
commit c8d392ea3b
+5 -16
View File
@@ -4309,28 +4309,17 @@ class EntropyRepository(EntropyRepositoryBase):
raise SystemDatabaseError("SystemDatabaseError: %s" % (mytxt,))
pingus.ping(action_str)
mytxt = "Repository is corrupted, missing SQL tables!"
self._cursor().execute("""
SELECT name FROM SQLITE_MASTER WHERE type = (?) AND name = (?)
""", ("table", "baseinfo"))
SELECT count(name) FROM SQLITE_MASTER WHERE type = "table" AND (
name = "extrainfo" OR name = "baseinfo" OR name = "keywords" )
""")
rslt = self._cursor().fetchone()
if rslt is None:
mytxt = "baseinfo error. Either does not exist or corrupted."
raise SystemDatabaseError("SystemDatabaseError: %s" % (mytxt,))
self._cursor().execute("""
SELECT name FROM SQLITE_MASTER WHERE type = (?) AND name = (?)
""", ("table", "extrainfo"))
rslt = self._cursor().fetchone()
if rslt is None:
mytxt = "extrainfo error. Either does not exist or corrupted."
elif rslt[0] != 3:
raise SystemDatabaseError("SystemDatabaseError: %s" % (mytxt,))
try:
self.checksum()
except (DatabaseError,) as err:
raise SystemDatabaseError("SystemDatabaseError: checksum => %s" % (
err,))
def _getIdpackagesDifferences(self, foreign_package_ids):
"""
Return differences between in-repository package identifiers and