From e8dae77e5e5bb3ce7f6fd88fa608ba2ee58ada71 Mon Sep 17 00:00:00 2001 From: GamaC0de Date: Wed, 27 Apr 2016 01:50:28 +0300 Subject: [Checksum] Update --- module/plugins/hooks/Checksum.py | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 14fca4634..9ecd79a0a 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -38,7 +38,7 @@ def compute_checksum(local_file, algorithm): class Checksum(Addon): __name__ = "Checksum" __type__ = "hook" - __version__ = "0.28" + __version__ = "0.29" __status__ = "broken" __config__ = [("activated" , "bool" , "Activated" , False ), @@ -130,22 +130,26 @@ class Checksum(Addon): data['hash'][key] = data[key] break - for key in self.algorithms: - if key in data['hash']: - checksum = compute_checksum(local_file, key.replace("-", "").lower()) - if checksum: - if checksum == data['hash'][key].lower(): - self.log_info(_('File integrity of "%s" verified by %s checksum (%s)') % - (pyfile.name, key.upper(), checksum)) - break + if len(data['hash']) > 0: + for key in self.algorithms: + if key in data['hash']: + checksum = compute_checksum(local_file, key.replace("-", "").lower()) + if checksum: + if checksum == data['hash'][key].lower(): + self.log_info(_('File integrity of "%s" verified by %s checksum (%s)') % + (pyfile.name, key.upper(), checksum)) + break + + else: + self.log_warning(_("%s checksum for file %s does not match (%s != %s)") % + (key.upper(), pyfile.name, checksum, data['hash'][key].lower())) + self.check_failed(pyfile, local_file, "Checksums do not match") + else: - self.log_warning(_("%s checksum for file %s does not match (%s != %s)") % - (key.upper(), pyfile.name, checksum, data['hash'][key].lower())) - self.check_failed(pyfile, local_file, "Checksums do not match") - else: - self.log_warning(_("Unsupported hashing algorithm"), key.upper()) - else: - self.log_warning(_("Unable to validate checksum for file: ") + pyfile.name) + self.log_warning(_("Unsupported hashing algorithm"), key.upper()) + + else: + self.log_warning(_('Unable to validate checksum for file: "%s"') % pyfile.name) def check_failed(self, pyfile, local_file, msg): -- cgit v1.2.3