[entropy.db] drop strings= keyword arg from checksum()

This is no longer in use.
This commit is contained in:
Fabio Erculiani
2013-08-10 11:33:02 +02:00
parent 2f4884a4ad
commit b5d7dfeb90
3 changed files with 35 additions and 92 deletions
+1 -4
View File
@@ -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
+15 -37
View File
@@ -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):
+19 -51
View File
@@ -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