From b5d7dfeb90a14bb39185930654cd289fec28232d Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Sat, 10 Aug 2013 11:33:02 +0200 Subject: [PATCH] [entropy.db] drop strings= keyword arg from checksum() This is no longer in use. --- lib/entropy/db/skel.py | 5 +-- lib/entropy/db/sql.py | 52 +++++++++-------------------- lib/entropy/db/sqlite.py | 70 +++++++++++----------------------------- 3 files changed, 35 insertions(+), 92 deletions(-) diff --git a/lib/entropy/db/skel.py b/lib/entropy/db/skel.py index b4eba2131..8c407fb6e 100644 --- a/lib/entropy/db/skel.py +++ b/lib/entropy/db/skel.py @@ -4279,8 +4279,7 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore): raise NotImplementedError() def checksum(self, do_order = False, strict = True, - strings = True, include_signatures = False, - include_dependencies = False): + include_signatures = False, include_dependencies = False): """ Get Repository metadata checksum, useful for integrity verification. Note: result is cached in EntropyRepository.live_cache (dict). @@ -4289,8 +4288,6 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore): @type do_order: bool @keyword strict: improve checksum accuracy @type strict: bool - @keyword strings: return checksum in md5 hex form - @type strings: bool @keyword include_signatures: also include packages signatures (GPG, SHA1, SHA2, etc) into the returned hash @type include_signatures: bool diff --git a/lib/entropy/db/sql.py b/lib/entropy/db/sql.py index 9e2c615ac..beb0ee7d8 100644 --- a/lib/entropy/db/sql.py +++ b/lib/entropy/db/sql.py @@ -4867,14 +4867,13 @@ class EntropySQLRepository(EntropyRepositoryBase): raise NotImplementedError() def checksum(self, do_order = False, strict = True, - strings = True, include_signatures = False, + include_signatures = False, include_dependencies = False): """ Reimplemented from EntropyRepositoryBase. """ - cache_key = "checksum_%s_%s_%s_%s_%s" % ( - do_order, strict, strings, - include_signatures, include_dependencies) + cache_key = "checksum_%s_%s_True_%s_%s" % ( + do_order, strict, include_signatures, include_dependencies) cached = self._getLiveCache(cache_key) if cached is not None: return cached @@ -4902,16 +4901,11 @@ class EntropySQLRepository(EntropyRepositoryBase): for record in cursor: m.update(repr(record)) - if strings: - m = hashlib.sha1() + m = hashlib.sha1() if not self._doesTableExist("baseinfo"): - if strings: - m.update(const_convert_to_rawstring("~empty~")) - result = m.hexdigest() - else: - result = "~empty_db~" - return result + m.update(const_convert_to_rawstring("~empty~")) + return m.hexdigest() if strict: cur = self._cursor().execute(""" @@ -4922,10 +4916,8 @@ class EntropySQLRepository(EntropyRepositoryBase): SELECT idpackage, atom, name, version, versiontag, revision, branch, slot, etpapi, `trigger` FROM baseinfo %s""" % (package_id_order,)) - if strings: - do_update_hash(m, cur) - else: - a_hash = hash(tuple(cur)) + + do_update_hash(m, cur) if strict: cur = self._cursor().execute(""" @@ -4936,10 +4928,8 @@ class EntropySQLRepository(EntropyRepositoryBase): SELECT idpackage, description, homepage, download, size, digest, datecreation FROM extrainfo %s """ % (package_id_order,)) - if strings: - do_update_hash(m, cur) - else: - b_hash = hash(tuple(cur)) + + do_update_hash(m, cur) if include_signatures: # be optimistic and delay if condition, @@ -4948,34 +4938,22 @@ class EntropySQLRepository(EntropyRepositoryBase): cur = self._cursor().execute(""" SELECT idpackage, sha1, gpg FROM packagesignatures %s""" % (package_id_order,)) - if strings: - do_update_hash(m, cur) - else: - b_hash = "%s-%s" % (b_hash, hash(tuple(cur)),) + do_update_hash(m, cur) if include_dependencies: cur = self._cursor().execute(""" SELECT * from dependenciesreference %s """ % (dependenciesref_order,)) - if strings: - do_update_hash(m, cur) - else: - b_hash = "%s-%s" % (b_hash, hash(tuple(cur)),) + do_update_hash(m, cur) cur = self._cursor().execute(""" SELECT * from dependencies %s """ % (dependencies_order,)) - if strings: - do_update_hash(m, cur) - else: - b_hash = "%s-%s" % (b_hash, hash(tuple(cur)),) - - if strings: - result = m.hexdigest() - else: - result = "%s:%s:0:0:0" % (a_hash, b_hash,) + do_update_hash(m, cur) + result = m.hexdigest() self._setLiveCache(cache_key, result) + return result def storeInstalledPackage(self, package_id, repoid, source = 0): diff --git a/lib/entropy/db/sqlite.py b/lib/entropy/db/sqlite.py index 4fc59ae0e..10969463c 100644 --- a/lib/entropy/db/sqlite.py +++ b/lib/entropy/db/sqlite.py @@ -1754,8 +1754,7 @@ class EntropySQLiteRepository(EntropySQLRepository): return os.path.getmtime(self._db) def checksum(self, do_order = False, strict = True, - strings = True, include_signatures = False, - include_dependencies = False): + include_signatures = False, include_dependencies = False): """ Reimplemented from EntropySQLRepository. We have to handle _baseinfo_extrainfo_2010. @@ -1767,13 +1766,12 @@ class EntropySQLiteRepository(EntropySQLRepository): self).checksum( do_order = do_order, strict = strict, - strings = strings, include_signatures = include_signatures) # backward compatibility # !!! keep aligned !!! - cache_key = "checksum_%s_%s_%s_%s" % (do_order, strict, strings, - include_signatures) + cache_key = "checksum_%s_%s_True_%s" % ( + do_order, strict, include_signatures) cached = self._getLiveCache(cache_key) if cached is not None: return cached @@ -1807,16 +1805,12 @@ class EntropySQLiteRepository(EntropySQLRepository): for record in cursor: m.update(repr(record)) - if strings: - m = hashlib.sha1() + m = hashlib.sha1() if not self._doesTableExist("baseinfo"): - if strings: - m.update(const_convert_to_rawstring("~empty~")) - result = m.hexdigest() - else: - result = "~empty_db~" - self._setLiveCache(cache_key, result) + m.update(const_convert_to_rawstring("~empty~")) + result = m.hexdigest() + self._setLiveCache(cache_key, result) return result if strict: @@ -1828,10 +1822,8 @@ class EntropySQLiteRepository(EntropySQLRepository): SELECT idpackage, atom, name, version, versiontag, revision, branch, slot, etpapi, trigger FROM baseinfo %s""" % (package_id_order,)) - if strings: - do_update_hash(m, cur) - else: - a_hash = hash(tuple(cur)) + + do_update_hash(m, cur) if strict: cur = self._cursor().execute(""" @@ -1842,35 +1834,24 @@ class EntropySQLiteRepository(EntropySQLRepository): SELECT idpackage, description, homepage, download, size, digest, datecreation FROM extrainfo %s """ % (package_id_order,)) - if strings: - do_update_hash(m, cur) - else: - b_hash = hash(tuple(cur)) + + do_update_hash(m, cur) cur = self._cursor().execute(""" SELECT category FROM categories %s """ % (category_order,)) - if strings: - do_update_hash(m, cur) - else: - c_hash = hash(tuple(cur)) + do_update_hash(m, cur) d_hash = "0" e_hash = "0" if strict: cur = self._cursor().execute(""" SELECT * FROM licenses %s""" % (license_order,)) - if strings: - do_update_hash(m, cur) - else: - d_hash = hash(tuple(cur)) + do_update_hash(m, cur) cur = self._cursor().execute('select * from flags %s' % ( flags_order,)) - if strings: - do_update_hash(m, cur) - else: - e_hash = hash(tuple(cur)) + do_update_hash(m, cur) if include_signatures: try: @@ -1888,34 +1869,21 @@ class EntropySQLiteRepository(EntropySQLRepository): cur = self._cursor().execute(""" SELECT idpackage, sha1 FROM packagesignatures %s""" % (package_id_order,)) - if strings: - do_update_hash(m, cur) - else: - b_hash = "%s-%s" % (b_hash, hash(tuple(cur)),) + + do_update_hash(m, cur) if include_dependencies: cur = self._cursor().execute(""" SELECT * from dependenciesreference %s """ % (dependenciesref_order,)) - if strings: - do_update_hash(m, cur) - else: - b_hash = "%s-%s" % (b_hash, hash(tuple(cur)),) + do_update_hash(m, cur) cur = self._cursor().execute(""" SELECT * from dependencies %s """ % (dependencies_order,)) - if strings: - do_update_hash(m, cur) - else: - b_hash = "%s-%s" % (b_hash, hash(tuple(cur)),) - - if strings: - result = m.hexdigest() - else: - result = "%s:%s:%s:%s:%s" % ( - a_hash, b_hash, c_hash, d_hash, e_hash) + do_update_hash(m, cur) + result = m.hexdigest() self._setLiveCache(cache_key, result) return result