summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Plasa <dplasa@gmail.com>2020-07-06 00:32:03 +0200
committerDaniel Plasa <dplasa@gmail.com>2020-07-06 00:32:03 +0200
commit07fa634e5b25a4324f7c950702cfdb486858b2a0 (patch)
tree5af00246976e5a2444cb571169e18fd7f5bc2f30
parentadd docu on esp32 (diff)
downloadFTPCLientServer-07fa634e5b25a4324f7c950702cfdb486858b2a0.tar
FTPCLientServer-07fa634e5b25a4324f7c950702cfdb486858b2a0.tar.gz
FTPCLientServer-07fa634e5b25a4324f7c950702cfdb486858b2a0.tar.bz2
FTPCLientServer-07fa634e5b25a4324f7c950702cfdb486858b2a0.tar.lz
FTPCLientServer-07fa634e5b25a4324f7c950702cfdb486858b2a0.tar.xz
FTPCLientServer-07fa634e5b25a4324f7c950702cfdb486858b2a0.tar.zst
FTPCLientServer-07fa634e5b25a4324f7c950702cfdb486858b2a0.zip
-rw-r--r--FTPServer.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/FTPServer.cpp b/FTPServer.cpp
index bad2fb2..e707589 100644
--- a/FTPServer.cpp
+++ b/FTPServer.cpp
@@ -127,7 +127,6 @@ void FTPServer::handleFTP()
iniVariables();
cmdState = cWait;
}
-
else if (cmdState == cWait) // FTP control server waiting for connection
{
if (controlServer.hasClient())
@@ -435,6 +434,7 @@ int8_t FTPServer::processCommand()
String ip = control.localIP().toString();
ip.replace(".", ",");
sendMessage_P(227, PSTR("Entering Passive Mode (%s,%d,%d)."), ip.c_str(), dataPort >> 8, dataPort & 255);
+ //sendMessage_P(227, PSTR("Entering Passive Mode (0,0,0,0,%d,%d)."), dataPort >> 8, dataPort & 255);
}
//
@@ -605,7 +605,7 @@ int8_t FTPServer::processCommand()
file = dir.openNextFile();
#endif
}
-
+
if (FTP_CMD(MLSD) == command)
{
control.println(F("226-options: -a -l\r\n"));
@@ -679,7 +679,12 @@ int8_t FTPServer::processCommand()
{
FTP_DEBUG_MSG("STOR '%s'", path.c_str());
if (!file)
- file = THEFS.open(path, "w");
+ {
+ file = THEFS.open(path, "w"); // open file, truncate it if already exists
+ f.close(); // this performs a sync on LittleFS so that the actual
+ // space used by the file in FS gets released
+ file = THEFS.open(path, "w"); // re-open file for writing
+ }
if (!file)
{
sendMessage_P(451, PSTR("Cannot open/create \"%s\""), path.c_str());
@@ -1136,7 +1141,7 @@ String FTPServer::makeDateTimeStr(time_t ft)
//
void FTPServer::sendMessage_P(int16_t code, PGM_P fmt, ...)
{
- FTP_DEBUG_MSG(">>> %d %S", code, fmt);
+ FTP_DEBUG_MSG(">>> %d %s", code, fmt);
int size = 0;
char *p = NULL;
@@ -1163,4 +1168,4 @@ void FTPServer::sendMessage_P(int16_t code, PGM_P fmt, ...)
free(p);
}
}
-} \ No newline at end of file
+}