Mercurial > libervia-backend
comparison plugins/plugin_xep_0065.py @ 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 | 55d3ef84f01f |
children |
comparison
equal
deleted
inserted
replaced
177:8f56238309d9 | 178:bd24f2aed80c |
---|---|
352 else: | 352 else: |
353 self.sendErrorReply(socks5.REPLY_CONN_REFUSED) | 353 self.sendErrorReply(socks5.REPLY_CONN_REFUSED) |
354 | 354 |
355 def getProgress(self, data): | 355 def getProgress(self, data): |
356 """Fill data with position of current transfert""" | 356 """Fill data with position of current transfert""" |
357 data["size"] = self.filesize | |
358 try: | 357 try: |
359 data["position"] = str(self.dest_file.tell()) | 358 data["position"] = str(self.dest_file.tell()) |
359 data["size"] = self.filesize | |
360 except (ValueError, AttributeError): | 360 except (ValueError, AttributeError): |
361 data["position"] = "" | 361 pass |
362 | 362 |
363 def fileTransfered(self, d): | 363 def fileTransfered(self, d): |
364 info(_("File transfer completed, closing connection")) | 364 info(_("File transfer completed, closing connection")) |
365 self.transport.loseConnection() | 365 self.transport.loseConnection() |
366 try: | |
367 self.dest_file.close() | |
368 except: | |
369 pass | |
366 | 370 |
367 def updateTransfered(self, data): | 371 def updateTransfered(self, data): |
368 self.transfered+=len(data) | 372 self.transfered+=len(data) |
369 return data | 373 return data |
370 | 374 |