avatars rest fix

This commit is contained in:
ingvar1995 2016-05-25 16:05:16 +03:00
parent be4a592599
commit b2fa484bb3

View file

@ -242,22 +242,22 @@ class ReceiveAvatar(ReceiveTransfer):
if size > self.MAX_AVATAR_SIZE: if size > self.MAX_AVATAR_SIZE:
self.send_control(TOX_FILE_CONTROL['CANCEL']) self.send_control(TOX_FILE_CONTROL['CANCEL'])
remove(path + '.tmp') remove(path + '.tmp')
elif exists(path): elif not size:
if not size: self.send_control(TOX_FILE_CONTROL['CANCEL'])
self.send_control(TOX_FILE_CONTROL['CANCEL']) self._file.close()
self._file.close() if exists(path):
remove(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') remove(path + '.tmp')
else: else:
hash = self.get_file_id() self.send_control(TOX_FILE_CONTROL['RESUME'])
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'])
else: else:
self.send_control(TOX_FILE_CONTROL['RESUME']) self.send_control(TOX_FILE_CONTROL['RESUME'])