Skip Menu |

This queue is for tickets about the libnet CPAN distribution.

Report information
The Basics
Id: 36272
Status: open
Priority: 0/
Queue: libnet

People
Owner: Nobody in particular
Requestors: jochen.schug [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Net::FTP not seek'ing to the start of a file, breaks multiple transfers
Hi, seems Net::FTP doesn't seek to the start of file before transferring it. I noticed this when I wanted to upload the same file, consecutively, to two different FTP servers. On the second server, the file always showed up with "0 bytes". I fixed this by adding a seek($loc, 0, 0); just before the while(1) loop starting at line 746 of FTP.pm This affects at least versions 1.16 (which I used when noticing the bug) to 1.22 (to which I upgraded). Not sure if it's important, but the file in question was created using File::Temp and I did not open a file handle pointing to it at the time of the transfer. Environment info: perl -v: This is perl, v5.8.0 built for sun4-solaris uname -a: SunOS csdatamart01 5.8 Generic_117350-45 sun4u sparc SUNW,Sun-Fire-880 Best regards Jochen
Subject: Re: [rt.cpan.org #36272] Net::FTP not seek'ing to the start of a file, breaks multiple transfers
Date: Thu, 29 May 2008 07:36:00 -0500
To: bug-libnet [...] rt.cpan.org
From: Graham Barr <gbarr [...] pobox.com>
On May 29, 2008, at 7:14 AM, http://jochenschug.myopenid.com/ via RT wrote: Show quoted text
> seems Net::FTP doesn't seek to the start of file before > transferring it. > > I noticed this when I wanted to upload the same file, > consecutively, to > two different FTP servers. On the second server, the file always > showed > up with "0 bytes". > > I fixed this by adding a > > seek($loc, 0, 0);
If Net::FTP is passed a filehandle to read from I do not think it is the responsibility of Net::FTP to rewind that handle before reading it. If you want to pass a filehandle, it is the callers responsibility to ensure that handle is in the correct place for Net::FTP to start reading from. Graham.
Hi Graham, On Do. 29. Mai 2008, 08:37:01, gbarr@pobox.com wrote: Show quoted text
> If Net::FTP is passed a filehandle to read from I do not think it is > the responsibility of Net::FTP to rewind that handle before reading > it. If you want to pass a filehandle, it is the callers > responsibility to ensure that handle is in the correct place for > Net::FTP to start reading from.
I'm not passing it a file handle, I'm passing just two file names to the put() method like this: $ftp->put($file->{'tmpname'}, $file->{'filename'}); where $file->{'tmpname'} was created via File::Temp->new(). Well, at least I thought I am passing a file name, not a file handle. Just read the File::Temp documentation carefully and noticed that my assumption was wrong. Is Net::FTP's behavior in regards to file handles documented somewhere? I couldn't find a reference to this anywhere on the website, so it's at least unexpected. The documentation just says "you can pass a file handle or a file name", but doesn't go into detail what will happen from there on. Thanks! Jochen