[entropy.db] EntropyRepository.checksum: add "include_dependencies" argument
include_dependencies can be used to include dependencies information into the computed checksum.
This commit is contained in:
@@ -4279,7 +4279,8 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore):
|
||||
raise NotImplementedError()
|
||||
|
||||
def checksum(self, do_order = False, strict = True,
|
||||
strings = True, include_signatures = False):
|
||||
strings = True, include_signatures = False,
|
||||
include_dependencies = False):
|
||||
"""
|
||||
Get Repository metadata checksum, useful for integrity verification.
|
||||
Note: result is cached in EntropyRepository.live_cache (dict).
|
||||
@@ -4291,8 +4292,11 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore):
|
||||
@keyword strings: return checksum in md5 hex form
|
||||
@type strings: bool
|
||||
@keyword include_signatures: also include packages signatures (GPG,
|
||||
SHA1, SHA2, etc) into returned hash
|
||||
SHA1, SHA2, etc) into the returned hash
|
||||
@type include_signatures: bool
|
||||
@keyword include_dependencies: also include package dependencies into
|
||||
the returned hash
|
||||
@type include_dependencies: bool
|
||||
@return: repository checksum
|
||||
@rtype: string
|
||||
"""
|
||||
|
||||
+30
-18
@@ -4867,27 +4867,27 @@ class EntropySQLRepository(EntropyRepositoryBase):
|
||||
raise NotImplementedError()
|
||||
|
||||
def checksum(self, do_order = False, strict = True,
|
||||
strings = True, include_signatures = False):
|
||||
strings = True, include_signatures = False,
|
||||
include_dependencies = False):
|
||||
"""
|
||||
Reimplemented from EntropyRepositoryBase.
|
||||
"""
|
||||
cache_key = "checksum_%s_%s_%s_%s" % (do_order, strict, strings,
|
||||
include_signatures)
|
||||
cache_key = "checksum_%s_%s_%s_%s_%s" % (
|
||||
do_order, strict, strings,
|
||||
include_signatures, include_dependencies)
|
||||
cached = self._getLiveCache(cache_key)
|
||||
if cached is not None:
|
||||
return cached
|
||||
# avoid memleak with python3.x
|
||||
del cached
|
||||
|
||||
package_id_order = ''
|
||||
category_order = ''
|
||||
license_order = ''
|
||||
flags_order = ''
|
||||
package_id_order = ""
|
||||
depenenciesref_order = ""
|
||||
dependencies_order = ""
|
||||
if do_order:
|
||||
package_id_order = 'order by idpackage'
|
||||
category_order = 'order by category'
|
||||
license_order = 'order by license'
|
||||
flags_order = 'order by chost'
|
||||
package_id_order = "order by idpackage"
|
||||
dependenciesref_order = "order by iddependency"
|
||||
dependencies_order = "order by idpackage"
|
||||
|
||||
def do_update_hash(m, cursor):
|
||||
# this could slow things down a lot, so be careful
|
||||
@@ -4941,10 +4941,6 @@ class EntropySQLRepository(EntropyRepositoryBase):
|
||||
else:
|
||||
b_hash = hash(tuple(cur))
|
||||
|
||||
c_hash = '0'
|
||||
d_hash = '0'
|
||||
e_hash = '0'
|
||||
|
||||
if include_signatures:
|
||||
# be optimistic and delay if condition,
|
||||
# _doesColumnInTableExist
|
||||
@@ -4955,13 +4951,29 @@ class EntropySQLRepository(EntropyRepositoryBase):
|
||||
if strings:
|
||||
do_update_hash(m, cur)
|
||||
else:
|
||||
b_hash = "%s%s" % (b_hash, hash(tuple(cur)),)
|
||||
b_hash = "%s-%s" % (b_hash, hash(tuple(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)),)
|
||||
|
||||
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)
|
||||
result = "%s:%s:0:0:0" % (a_hash, b_hash,)
|
||||
|
||||
self._setLiveCache(cache_key, result)
|
||||
return result
|
||||
|
||||
+34
-12
@@ -1754,7 +1754,8 @@ class EntropySQLiteRepository(EntropySQLRepository):
|
||||
return os.path.getmtime(self._db)
|
||||
|
||||
def checksum(self, do_order = False, strict = True,
|
||||
strings = True, include_signatures = False):
|
||||
strings = True, include_signatures = False,
|
||||
include_dependencies = False):
|
||||
"""
|
||||
Reimplemented from EntropySQLRepository.
|
||||
We have to handle _baseinfo_extrainfo_2010.
|
||||
@@ -1779,15 +1780,19 @@ class EntropySQLiteRepository(EntropySQLRepository):
|
||||
# avoid memleak with python3.x
|
||||
del cached
|
||||
|
||||
package_id_order = ''
|
||||
category_order = ''
|
||||
license_order = ''
|
||||
flags_order = ''
|
||||
package_id_order = ""
|
||||
category_order = ""
|
||||
license_order = ""
|
||||
flags_order = ""
|
||||
depenenciesref_order = ""
|
||||
dependencies_order = ""
|
||||
if do_order:
|
||||
package_id_order = 'order by idpackage'
|
||||
category_order = 'order by category'
|
||||
license_order = 'order by license'
|
||||
flags_order = 'order by chost'
|
||||
package_id_order = "order by idpackage"
|
||||
category_order = "order by category"
|
||||
license_order = "order by license"
|
||||
flags_order = "order by chost"
|
||||
dependenciesref_order = "order by iddependency"
|
||||
dependencies_order = "order by idpackage"
|
||||
|
||||
def do_update_hash(m, cursor):
|
||||
# this could slow things down a lot, so be careful
|
||||
@@ -1850,8 +1855,8 @@ class EntropySQLiteRepository(EntropySQLRepository):
|
||||
else:
|
||||
c_hash = hash(tuple(cur))
|
||||
|
||||
d_hash = '0'
|
||||
e_hash = '0'
|
||||
d_hash = "0"
|
||||
e_hash = "0"
|
||||
if strict:
|
||||
cur = self._cursor().execute("""
|
||||
SELECT * FROM licenses %s""" % (license_order,))
|
||||
@@ -1886,7 +1891,24 @@ class EntropySQLiteRepository(EntropySQLRepository):
|
||||
if strings:
|
||||
do_update_hash(m, cur)
|
||||
else:
|
||||
b_hash = "%s%s" % (b_hash, hash(tuple(cur)),)
|
||||
b_hash = "%s-%s" % (b_hash, hash(tuple(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)),)
|
||||
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user