Skip to content

Commit

Permalink
Merge pull request #25 from crifurch/fix/dowload_wait_response_error
Browse files Browse the repository at this point in the history
Fix/dowload wait response error
  • Loading branch information
crifurch committed May 17, 2024
2 parents 81e4b4b + a2b5c5c commit add5a0e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/src/file_system/ftp_transfer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class FtpTransfer {
log?.call('Downloaded ${downloaded} of ${total} bytes');
},
).asFuture();
await _socket.read();
await _socket.flush();
await stream.close();
},
(error, stackTrace) {
Expand Down Expand Up @@ -110,7 +110,7 @@ class FtpTransfer {
uploaded += event.length;
final total = max(fileSize, uploaded);
onUploadProgress?.call(uploaded, total, uploaded / total * 100);
log?.call('Downloaded ${uploaded} of ${total} bytes');
log?.call('Uploaded ${uploaded} of ${total} bytes');
},
),
);
Expand Down
11 changes: 11 additions & 0 deletions lib/src/ftp/ftp_socket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,17 @@ class FtpSocket {
return FtpResponse(code: code, message: result);
}

/// Flush the response from the server
Future<void> flush() async {
if (_socket.available() > 0) {
_socket.readMessage();
}
await Future.delayed(const Duration(milliseconds: 300));
if (_socket.available() > 0) {
await flush();
}
}

/// Send message to the server
///
/// if [command] is true then the message will be sent as a command
Expand Down

0 comments on commit add5a0e

Please sign in to comment.