ftp.size lies after NLST command

Bug #244449 reported by Rehan Khan
2
Affects Status Importance Assigned to Milestone
Smart Package Manager
New
Undecided
Unassigned

Bug Description

Imported: http://tracker.labix.org/issue312

Reason for Import: patch review

further details: https://blueprints.launchpad.net/smart/+spec/bug-reporting-migration

#msg1159 (view) Author: Seweryn Walentynowicz Date: 2007-06-25.21:29:44

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.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.