2008-06-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Use digits to find first byte of file size, which makes the 
intention
	of the code clearer.
	* src/FtpConnection.cc

	Don't call validateTotalLength() when size is 0.
	* src/FtpNegotiationCommand.cc
pull/1/head
Tatsuhiro Tsujikawa 2008-06-26 10:54:50 +00:00
parent 23b6a43585
commit c42c8b7f9c
3 changed files with 18 additions and 4 deletions

View File

@ -1,3 +1,12 @@
2008-06-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Use digits to find first byte of file size, which makes the intention
of the code clearer.
* src/FtpConnection.cc
Don't call validateTotalLength() when size is 0.
* src/FtpNegotiationCommand.cc
2008-06-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Updated po files.

View File

@ -285,6 +285,7 @@ unsigned int FtpConnection::receivePasvResponse(std::pair<std::string, uint16_t>
unsigned int FtpConnection::receiveRetrResponse(uint64_t& size)
{
static const char* DIGITS = "0123456789";
std::pair<unsigned int, std::string> response;
if(bulkReceiveResponse(response)) {
if(response.first == 150 || response.first == 125) {
@ -295,11 +296,11 @@ unsigned int FtpConnection::receiveRetrResponse(uint64_t& size)
std::string& res = response.second;
std::string::size_type start;
if((start = res.find_first_of("(")) != std::string::npos &&
(start = res.find_first_not_of("( ", start)) != std::string::npos) {
(start = res.find_first_of(DIGITS, start)) != std::string::npos) {
// now start points to the first byte of the size string.
// now start points to the first digit of the size string.
std::string::size_type end =
res.find_first_not_of("0123456789", start);
res.find_first_not_of(DIGITS, start);
if(end != std::string::npos) {
size = Util::parseULLInt(res.substr(start, end-start));

View File

@ -421,7 +421,11 @@ bool FtpNegotiationCommand::recvRetr() {
return onFileSizeDetermined(size);
} else {
_requestGroup->validateTotalLength(size);
// size == 0 means file size could not be retrieved from the response of
// RETR raw command.
if(size > 0) {
_requestGroup->validateTotalLength(size);
}
}
if(e->option->getAsBool(PREF_FTP_PASV)) {