From c8d392ea3bb002aa2ac4bf08faccc6f5cbc25988 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Wed, 14 Jul 2010 23:48:39 +0200 Subject: [PATCH] [entropy.db] improve EntropyRepository.validateDatabase() reliability --- libraries/entropy/db/__init__.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/libraries/entropy/db/__init__.py b/libraries/entropy/db/__init__.py index 41a3a7f0b..0405070ac 100644 --- a/libraries/entropy/db/__init__.py +++ b/libraries/entropy/db/__init__.py @@ -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