Skip to content

Commit 4feb908

Browse files
fix for if not printed number of bytes processed at end of file found
1 parent a7efef9 commit 4feb908

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

examples/sftpclient/sftpclient.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ static void myStatusCb(WOLFSSH* sshIn, word32* bytes, char* name)
154154
word32 currentTime;
155155
#ifndef WOLFSSH_NO_TIMESTAMP
156156
static word32 lastOutputTime = 0;
157+
static word32 lastPrintedBytes[2] = {0, 0};
157158
word32 elapsedTime;
158159
#endif
159160
char buf[80];
@@ -162,12 +163,24 @@ static void myStatusCb(WOLFSSH* sshIn, word32* bytes, char* name)
162163
#ifndef WOLFSSH_NO_TIMESTAMP
163164
currentTime = current_time(0);
164165
if (currentTime == lastOutputTime) {
165-
return;
166+
if (bytes[0] != lastPrintedBytes[0] || bytes[1] != lastPrintedBytes[1]) {
167+
/* Progress made in the same second — throttle but track latest */
168+
lastPrintedBytes[0] = bytes[0];
169+
lastPrintedBytes[1] = bytes[1];
170+
return;
171+
}
172+
/* bytes unchanged: EOF final call — fall through to print */
173+
}
174+
else {
175+
lastOutputTime = currentTime;
166176
}
167-
lastOutputTime = currentTime;
177+
lastPrintedBytes[0] = bytes[0];
178+
lastPrintedBytes[1] = bytes[1];
168179
if (WSTRNCMP(currentFile, name, WSTRLEN(name)) != 0) {
169180
startTime = current_time(1);
170181
lastOutputTime = 0; /* Reset timer for new file transfer */
182+
lastPrintedBytes[0] = 0;
183+
lastPrintedBytes[1] = 0;
171184
WMEMSET(currentFile, 0, WOLFSSH_MAX_FILENAME);
172185
WSTRNCPY(currentFile, name, WOLFSSH_MAX_FILENAME);
173186
}

0 commit comments

Comments
 (0)