From 8da309e51e1016c45f0fc04a087c3567fd0b905e Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 29 May 2020 21:06:10 +0200 Subject: [PATCH] plugin XEP-0300; fixed use of calculateHash with getHasher --- sat/plugins/plugin_xep_0300.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sat/plugins/plugin_xep_0300.py b/sat/plugins/plugin_xep_0300.py index baef30ee..0731b96f 100644 --- a/sat/plugins/plugin_xep_0300.py +++ b/sat/plugins/plugin_xep_0300.py @@ -109,16 +109,15 @@ class XEP_0300(object): /!\\ 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 @@ class XEP_0300(object): 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