file_props.size is an integer

This commit is contained in:
Yann Leboulanger 2013-11-02 09:00:16 +01:00
parent c56b9e9267
commit 4da8a480d0
4 changed files with 12 additions and 11 deletions

View File

@ -2072,7 +2072,7 @@ class FileRequestReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
if name == 'name':
self.file_props.name = val
if name == 'size':
self.file_props.size = val
self.file_props.size = int(val)
if name == 'hash':
self.file_props.algo = child.getAttr('algo')
self.file_props.hash_ = val
@ -2112,7 +2112,7 @@ class FileRequestReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
if name == 'name':
self.file_props.name = val
if name == 'size':
self.file_props.size = val
self.file_props.size = int(val)
mime_type = si.getAttr('mime-type')
if mime_type is not None:
self.file_props.mime_type = mime_type

View File

@ -193,7 +193,7 @@ class JingleContent(object):
else:
# if the file is less than 10 mb, then it is small
# lets calculate it right away
if int(self.file_props.size) < 10000000 and not \
if self.file_props.size < 10000000 and not \
self.file_props.hash_:
h = self._calcHash()
file_tag.addChild(node=h)

View File

@ -646,7 +646,7 @@ class Socks5:
self.file_props.last_time
self.file_props.last_time = current_time
self.file_props.received_len = self.size
if self.size >= int(self.file_props.size):
if self.size >= self.file_props.size:
self.state = 8 # end connection
self.file_props.error = 0
self.disconnect()
@ -688,7 +688,7 @@ class Socks5:
self.file_props.last_time = current_time
self.file_props.received_len += lenn
self.remaining_buff = ''
if self.file_props.received_len == int(self.file_props.size):
if self.file_props.received_len == self.file_props.size:
self.rem_fd(fd)
self.disconnect()
self.file_props.error = 0
@ -728,7 +728,7 @@ class Socks5:
self.disconnect()
self.file_props.error = -6 # file system error
return 0
if self.file_props.received_len >= int(self.file_props.size):
if self.file_props.received_len >= self.file_props.size:
# transfer completed
self.rem_fd(fd)
self.disconnect()

View File

@ -407,6 +407,7 @@ class FileTransfersWindow:
propose_resume=not dl_finished, on_response=on_response,
transient_for=dialog2)
dialog.set_destroy_with_parent(True)
return
else:
dirname = os.path.dirname(file_path)
if not os.access(dirname, os.W_OK) and os.name != 'nt':
@ -489,7 +490,7 @@ class FileTransfersWindow:
file_props.completed = True
text = self._format_percent(100)
received_size = int(file_props.received_len)
full_size = int(file_props.size)
full_size = file_props.size
text += helpers.convert_bytes(received_size) + '/' + \
helpers.convert_bytes(full_size)
self.model.set(iter_, C_PROGRESS, text)
@ -498,7 +499,7 @@ class FileTransfersWindow:
self.model.set(iter_, C_PULSE, 1)
text = _('Checking file...') + '\n'
received_size = int(file_props.received_len)
full_size = int(file_props.size)
full_size = file_props.size
text += helpers.convert_bytes(received_size) + '/' + \
helpers.convert_bytes(full_size)
self.model.set(iter_, C_PROGRESS, text)
@ -512,7 +513,7 @@ class FileTransfersWindow:
elif status == 'hash_error':
text = _('File error') + '\n'
received_size = int(file_props.received_len)
full_size = int(file_props.size)
full_size = file_props.size
text += helpers.convert_bytes(received_size) + '/' + \
helpers.convert_bytes(full_size)
self.model.set(iter_, C_PROGRESS, text)
@ -602,7 +603,7 @@ class FileTransfersWindow:
Change the progress of a transfer with new transfered size
"""
file_props = FilesProp.getFilePropByType(typ, sid)
full_size = int(file_props.size)
full_size = file_props.size
if full_size == 0:
percent = 0
else:
@ -711,7 +712,7 @@ class FileTransfersWindow:
file_props.type_ = 's'
file_props.desc = file_desc
file_props.elapsed_time = 0
file_props.size = str(stat[6])
file_props.size = stat[6]
file_props.sender = account
file_props.receiver = contact
file_props.tt_account = account