From f0f54f11e70ba33a67f212ed04f8fc93ac3f4c05 Mon Sep 17 00:00:00 2001 From: lujianyu Date: Thu, 16 Apr 2020 01:35:58 +0800 Subject: [PATCH] fix giampaolo#524: download hang when file byte=0 --- pyftpdlib/handlers.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyftpdlib/handlers.py b/pyftpdlib/handlers.py index a888eb9f..c83b38d9 100644 --- a/pyftpdlib/handlers.py +++ b/pyftpdlib/handlers.py @@ -659,7 +659,13 @@ def push_with_producer(self, producer): self.initiate_send = self.initiate_sendfile return debug("starting transfer using send()", self) - AsyncChat.push_with_producer(self, producer) + if self.file_obj: + if os.path.getsize(self.file_obj.name) > 0: + # send if file size > 0 + debug("%s" % os.path.getsize(self.file_obj.name)) + AsyncChat.push_with_producer(self, producer) + else: + AsyncChat.push_with_producer(self, producer) def close_when_done(self): asynchat.async_chat.close_when_done(self)