[issue312] ftp.size lies after NLST command
seweryn at Labix Tracker
tracker at labix.org
Mon Jun 25 14:29:44 PDT 2007
New submission from seweryn <S.Walentynowicz at walor.torun.pl>:
If we define channel, which use ftp protocol, sometimes we got an error:
"Server reports unexpected size"
It happens when file size in repodata differs from file size reading direct
from FTP session before fetching a file. This size is reading by FTP command
SIZE <filename>. As described in RFC this command returns size in bytes
( same as size in metadata file ) if FTP mode is binary, but in ASCII ftp
mode this size is greater ( including LF appended to end of each line, and
^Z at the end of file ).
And now in smart fetcher.py code we have:
ftp.nlst(filename)
...
try:
total = ftp.size(filename)
...
if size != total:
raise.Error,_("Server reports unexpected size")
calling ftp.nlst function from python ftplib set mode of FTP session to ASCII
( send command 'TYPE A' before 'NLST ...' ). After that size reading with
ftp.size was greater than real bytes size of file.
I've patched my local copy with :
try:
+ ftp.voidcmd('TYPE I')
total = ftp.size(filename)
and now all works fine.
----------
messages: 1159
nosy: Seweryn Walentynowicz
priority: bug
project: smart
status: unread
title: ftp.size lies after NLST command
_______________________________________
Labix issue tracker <tracker at labix.org>
<http://tracker.labix.org/issue312>
_______________________________________
More information about the Smart
mailing list