Skip Menu |

This queue is for tickets about the Net-FTP-AutoReconnect CPAN distribution.

Report information
The Basics
Id: 48392
Status: resolved
Priority: 0/
Queue: Net-FTP-AutoReconnect

People
Owner: GIFF [...] cpan.org
Requestors: lee.johnson [...] netbanx.com
Cc:
AdminCc:

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



Subject: Patch to improve debug message handling
Date: Mon, 03 Aug 2009 15:04:02 +0100
To: bug-Net-FTP-AutoReconnect [...] rt.cpan.org
From: Lee Johnson <lee.johnson [...] netbanx.com>
We've recently had reason to use your Net::FTP::AutoReconnect module to help with transfers to some seriously shakey ftp servers. Whilst adding the module and running my own ftp tests I noticed a couple of things that could be added to improve the debug message and also a bug in the way a couple of return values were handled. I've attached/appended the patch, it applies to the current revision of the module, 0.2, on CPAN: - module now reports difference between initial connection and reconnection and uses passed Debug arg to Net::FTP as well as $ENV{DEBUG}, - $@ used in error message when Net::FTP object fails to connect, - removed defined check on return value in subs cwd and cdup because when these commands fail they return '' not undef. Show quoted text
-------- PATCH FOLLOWS -------- 79a80
> %{ $self->{args} } = @_;
81c82 < $self->reconnect(); ---
> $self->reconnect( 0 );
103,104c104,108 < warn "Reconnecting!\n" < if ($ENV{DEBUG}); ---
> my $is_reconnect = shift; > my $connection_type = ($is_reconnect) ? "Reconnecting" :
"Connecting";
> > warn join(' ',ref($self),$connection_type) > if ($ENV{DEBUG} or $self->{args}{Debug});
107c111 < or die "Couldn't create new FTP object\n"; ---
> or die "Couldn't create new FTP object: $@\n";
162c166 < $self->reconnect(); ---
> $self->reconnect( 1 );
238c242 < if (defined($ret)) ---
> if ($ret)
251c255 < if (defined($ret)) ---
> if ($ret)

Message body is not shown because sender requested not to inline it.

Thanks, Lee! Could you re-post your patch in unified diff format (diff - u)? patch(1) is rejecting this one.
Subject: Re: [rt.cpan.org #48392] Patch to improve debug message handling
Date: Mon, 10 Aug 2009 08:43:50 +0100
To: "bug-Net-FTP-AutoReconnect [...] rt.cpan.org" <bug-Net-FTP-AutoReconnect [...] rt.cpan.org>
From: Lee Johnson <lee.johnson [...] netbanx.com>
Sure, diff -u patch attached. On Sun, 2009-08-09 at 20:55 +0100, GIFF via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=48392 > > > Thanks, Lee! Could you re-post your patch in unified diff format (diff - > u)? patch(1) is rejecting this one. > >

Message body is not shown because sender requested not to inline it.

Thanks, that applied without any errors! I have a question about the argument handling in the constructor. You add a line like this: %{ $self->{args} } = @_; In addition to this original line: $self->{newargs} = \@_; First, does this work right? The docs for Net::FTP say that its first argument is a hostname, and I get an "Odd number of elements in hash assignment" warning when I call it with a hostname like this: Net::FTP::AutoReconnect->new('example.com', Debug => 0); Second, we end up with basically the same information in $self->{args} and $self->{newargs}. Probably it makes more sense to get rid of $self- Show quoted text
>{newargs} and just use $self->{args} to create the new connection, or
get rid of $self->{args} and use the debug stuff built into Net::Cmd. Using Net::Cmd's debug stuff seems cleaner. Let me know your thoughts, and thanks again!
Subject: Re: [rt.cpan.org #48392] Patch to improve debug message handling
Date: Mon, 10 Aug 2009 16:32:58 +0100
To: "bug-Net-FTP-AutoReconnect [...] rt.cpan.org" <bug-Net-FTP-AutoReconnect [...] rt.cpan.org>
From: Lee Johnson <lee.johnson [...] netbanx.com>
On Mon, 2009-08-10 at 16:23 +0100, GIFF via RT wrote: Show quoted text
> I have a question about the argument handling in the constructor. You > add a line like this: > > %{ $self->{args} } = @_; > > In addition to this original line: > > $self->{newargs} = \@_; > > First, does this work right? The docs for Net::FTP say that its first > argument is a hostname, and I get an "Odd number of elements in hash > assignment" warning when I call it with a hostname like this: > > Net::FTP::AutoReconnect->new('example.com', Debug => 0);
Ah, I missed that as I tend to call Net::FTP with new->( Host => 'example.com' ... ) - as per the Net::FTP docs: "HOST" is optional. If "HOST" is not given then it may instead be passed as the "Host" option. I guess we need to make this compatible either way. Show quoted text
> Second, we end up with basically the same information in $self->{args} > and $self->{newargs}. Probably it makes more sense to get rid of $self-
> >{newargs} and just use $self->{args} to create the new connection, or
> get rid of $self->{args} and use the debug stuff built into Net::Cmd. > Using Net::Cmd's debug stuff seems cleaner.
Yup, probably makes sense to get rid of one or the other. If Net::Cmd's debug is cleaner then I'd go with that. Lee.