handleMlsd method
Implementation
Future<void> handleMlsd(String argument, FtpSession session) async {
if (!await session.openDataConnection()) {
return;
}
try {
session.transferInProgress = true;
var dirContents = await session.fileOperations.listDirectory(argument);
logger.generalLog('Listing directory with MLSD: $argument');
for (FileSystemEntity entity in dirContents) {
if (!session.transferInProgress) break;
var stat = await entity.stat();
String facts = _formatMlsdFacts(entity, stat);
dataSocket!.write(facts);
}
if (session.transferInProgress) {
session.transferInProgress = false;
await session._closeDataSocket();
session.sendResponse('226 Transfer complete.');
}
} catch (e) {
session.sendResponse('550 Failed to list directory: $e');
logger.generalLog('Error listing directory with MLSD: $e');
session.transferInProgress = false;
await session._closeDataSocket();
}
}