From 0974b10241248d0d21ff3b448ee56e31ca3f7184 Mon Sep 17 00:00:00 2001 From: Goffi Date: Mon, 16 Aug 2010 21:08:19 +0800 Subject: [PATCH] Plugin XEP-0065: dest_file is now propertly closed after copy, and data dict in getProgress is not filled in case of file access error (file closed) --- plugins/plugin_xep_0065.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/plugin_xep_0065.py b/plugins/plugin_xep_0065.py index 94cfee06..d6af0d37 100755 --- a/plugins/plugin_xep_0065.py +++ b/plugins/plugin_xep_0065.py @@ -354,15 +354,19 @@ class SOCKSv5(protocol.Protocol, FileSender): def getProgress(self, data): """Fill data with position of current transfert""" - data["size"] = self.filesize try: data["position"] = str(self.dest_file.tell()) + data["size"] = self.filesize except (ValueError, AttributeError): - data["position"] = "" + pass def fileTransfered(self, d): info(_("File transfer completed, closing connection")) self.transport.loseConnection() + try: + self.dest_file.close() + except: + pass def updateTransfered(self, data): self.transfered+=len(data)