From b2fa484bb3300883477a09e0d636e56f3fb7ace1 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Wed, 25 May 2016 16:05:16 +0300 Subject: [PATCH] avatars rest fix --- src/file_transfers.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/file_transfers.py b/src/file_transfers.py index e4e0a4f..6ced355 100644 --- a/src/file_transfers.py +++ b/src/file_transfers.py @@ -242,22 +242,22 @@ class ReceiveAvatar(ReceiveTransfer): if size > self.MAX_AVATAR_SIZE: self.send_control(TOX_FILE_CONTROL['CANCEL']) remove(path + '.tmp') - elif exists(path): - if not size: - self.send_control(TOX_FILE_CONTROL['CANCEL']) - self._file.close() + elif not size: + self.send_control(TOX_FILE_CONTROL['CANCEL']) + self._file.close() + if exists(path): remove(path) + remove(path + '.tmp') + elif exists(path): + hash = self.get_file_id() + with open(path) as fl: + data = fl.read() + existing_hash = Tox.hash(data) + if hash == existing_hash: + self.send_control(TOX_FILE_CONTROL['CANCEL']) remove(path + '.tmp') else: - hash = self.get_file_id() - with open(path) as fl: - data = fl.read() - existing_hash = Tox.hash(data) - if hash == existing_hash: - self.send_control(TOX_FILE_CONTROL['CANCEL']) - remove(path + '.tmp') - else: - self.send_control(TOX_FILE_CONTROL['RESUME']) + self.send_control(TOX_FILE_CONTROL['RESUME']) else: self.send_control(TOX_FILE_CONTROL['RESUME'])