changeset 178:bd24f2aed80c

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)
author Goffi <goffi@goffi.org>
date Mon, 16 Aug 2010 21:08:19 +0800
parents 8f56238309d9
children d6c0c5dca9b9
files plugins/plugin_xep_0065.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/plugin_xep_0065.py	Mon Aug 16 21:06:03 2010 +0800
+++ b/plugins/plugin_xep_0065.py	Mon Aug 16 21:08:19 2010 +0800
@@ -354,15 +354,19 @@
 
     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)