From b9cbf809b5042af902cad5aa92453abc93c2e4b3 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Wed, 22 Jun 2016 16:09:44 +0300 Subject: [PATCH] windows bug fixes --- src/file_transfers.py | 7 ++++--- src/libtox.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/file_transfers.py b/src/file_transfers.py index e6200c1..fb64605 100644 --- a/src/file_transfers.py +++ b/src/file_transfers.py @@ -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) - - diff --git a/src/libtox.py b/src/libtox.py index 16dc2a4..edf2a12 100644 --- a/src/libtox.py +++ b/src/libtox.py @@ -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.')