# HG changeset patch # User Goffi # Date 1590779170 -7200 # Node ID ddf3ded93b7846e6d05ef3035aad699dc3771cad # Parent 4240b44842bbea6e1a4cbd46bb7f340d39405524 plugin XEP-0300; fixed use of calculateHash with getHasher diff -r 4240b44842bb -r ddf3ded93b78 sat/plugins/plugin_xep_0300.py --- a/sat/plugins/plugin_xep_0300.py Fri May 29 21:02:20 2020 +0200 +++ b/sat/plugins/plugin_xep_0300.py Fri May 29 21:06:10 2020 +0200 @@ -109,16 +109,15 @@ /!\\ blocking method, please use calculateHash instead @param file_obj(file): a file-like object - @param hasher(callable): the method to call to initialise hash object + @param hasher(hash object): the method to call to initialise hash object @return (str): the hex digest of the hash """ - hash_ = hasher() while True: buf = file_obj.read(BUFFER_SIZE) if not buf: break - hash_.update(buf) - return hash_.hexdigest() + hasher.update(buf) + return hasher.hexdigest() def calculateHash(self, file_obj, hasher): return threads.deferToThread(self._calculateHashBlocking, file_obj, hasher) @@ -134,7 +133,7 @@ def hashCalculated(hash_): return self.buildHashElt(hash_, algo) - hasher = self.ALGOS[algo] + hasher = self.getHasher(algo) hash_d = self.calculateHash(file_obj, hasher) hash_d.addCallback(hashCalculated) return hash_d