summaryrefslogtreecommitdiffstats
path: root/ESP8266FtpServer.cpp
diff options
context:
space:
mode:
authorsandtec65 <41759949+sandtec65@users.noreply.github.com>2018-07-27 14:59:30 +0200
committerGitHub <noreply@github.com>2018-07-27 14:59:30 +0200
commit5827505a3a47b5bf1618b7ed325b906a878f92b2 (patch)
treec71aa9fe06bb47e7bd8c7f07ef28add1e1340030 /ESP8266FtpServer.cpp
parentUpdate README.md (diff)
downloadFTPCLientServer-5827505a3a47b5bf1618b7ed325b906a878f92b2.tar
FTPCLientServer-5827505a3a47b5bf1618b7ed325b906a878f92b2.tar.gz
FTPCLientServer-5827505a3a47b5bf1618b7ed325b906a878f92b2.tar.bz2
FTPCLientServer-5827505a3a47b5bf1618b7ed325b906a878f92b2.tar.lz
FTPCLientServer-5827505a3a47b5bf1618b7ed325b906a878f92b2.tar.xz
FTPCLientServer-5827505a3a47b5bf1618b7ed325b906a878f92b2.tar.zst
FTPCLientServer-5827505a3a47b5bf1618b7ed325b906a878f92b2.zip
Diffstat (limited to 'ESP8266FtpServer.cpp')
-rw-r--r--ESP8266FtpServer.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/ESP8266FtpServer.cpp b/ESP8266FtpServer.cpp
index 7d25e9a..98401c6 100644
--- a/ESP8266FtpServer.cpp
+++ b/ESP8266FtpServer.cpp
@@ -782,11 +782,11 @@ return false;
boolean FtpServer::doStore()
{
- if( data.connected() )
+ // Avoid blocking by never reading more bytes than are available
+ int navail = data.available();
+
+ if (navail > 0)
{
- // Avoid blocking by never reading more bytes than are available
- int navail = data.available();
- if (navail <= 0) return true;
// And be sure not to overflow buf.
if (navail > FTP_BUF_SIZE) navail = FTP_BUF_SIZE;
int16_t nb = data.read((uint8_t*) buf, navail );
@@ -797,10 +797,16 @@ boolean FtpServer::doStore()
file.write((uint8_t*) buf, nb );
bytesTransfered += nb;
}
+ }
+ if( !data.connected() && (navail <= 0) )
+ {
+ closeTransfer();
+ return false;
+ }
+ else
+ {
return true;
}
- closeTransfer();
- return false;
}
void FtpServer::closeTransfer()