windows bug fixes

This commit is contained in:
ingvar1995 2016-06-22 16:09:44 +03:00
parent 5a0843d98b
commit b9cbf809b5
2 changed files with 8 additions and 6 deletions

View File

@ -230,7 +230,7 @@ class ReceiveTransfer(FileTransfer):
data = bytearray(data)
if self._file_size < position:
self._file.seek(0, 2)
self._file.write('\0' * (position - self._file_size))
self._file.write(b'\0' * (position - self._file_size))
self._file.seek(position)
self._file.write(data)
l = len(data)
@ -281,12 +281,14 @@ class ReceiveAvatar(ReceiveTransfer):
super(ReceiveAvatar, self).__init__(path + '.tmp', tox, friend_number, size, file_number)
if size > self.MAX_AVATAR_SIZE:
self.send_control(TOX_FILE_CONTROL['CANCEL'])
self._file.close()
remove(path + '.tmp')
elif not size:
self.send_control(TOX_FILE_CONTROL['CANCEL'])
self._file.close()
if exists(path):
remove(path)
self._file.close()
remove(path + '.tmp')
elif exists(path):
hash = self.get_file_id()
@ -295,6 +297,7 @@ class ReceiveAvatar(ReceiveTransfer):
existing_hash = Tox.hash(data)
if hash == existing_hash:
self.send_control(TOX_FILE_CONTROL['CANCEL'])
self._file.close()
remove(path + '.tmp')
else:
self.send_control(TOX_FILE_CONTROL['RESUME'])
@ -309,5 +312,3 @@ class ReceiveAvatar(ReceiveTransfer):
chdir(dirname(avatar_path))
remove(avatar_path)
rename(self._path, avatar_path)

View File

@ -1,5 +1,6 @@
from platform import system
from ctypes import CDLL
import util
class LibToxCore:
@ -9,7 +10,7 @@ class LibToxCore:
# libtoxcore and libsodium must be installed in your os
self._libtoxcore = CDLL('libtoxcore.so')
elif system() == 'Windows':
self._libtoxcore = CDLL('libs/libtox.dll')
self._libtoxcore = CDLL(util.curr_directory() + '/libs/libtox.dll')
else:
raise OSError('Unknown system.')
@ -25,7 +26,7 @@ class LibToxAV:
self._libtoxav = CDLL('libtoxav.so')
elif system() == 'Windows':
# on Windows av api is in libtox.dll
self._libtoxav = CDLL('libs/libtox.dll')
self._libtoxav = CDLL(util.curr_directory() + '/libs/libtox.dll')
else:
raise OSError('Unknown system.')
@ -41,7 +42,7 @@ class LibToxEncryptSave:
self._lib_tox_encrypt_save = CDLL('libtoxencryptsave.so')
elif system() == 'Windows':
# on Windows profile encryption api is in libtox.dll
self._lib_tox_encrypt_save = CDLL('libs/libtox.dll')
self._lib_tox_encrypt_save = CDLL(util.curr_directory() + '/libs/libtox.dll')
else:
raise OSError('Unknown system.')