When dealing with FTP-connections, we need to prepare for all kinds of remote connection failures. This library simply wraps exception handling and connection creation into a one nice package.
Created attachment 38132 [details] [review] Bug 14012 - Koha::FTP, a happy FTP-library to supercharge FTP operations. try { my $ftp = Koha::FTP->new( Net::FTP->new() ); my $currentDir = $ftp->getCurrentFtpDirectory(); $ftp->changeFtpDirectory($targetDirectory, $ftp); $ftp->putFtpFile($filePath, $ftp); $ftp->changeFtpDirectory($currentDir, $ftp); $ftp->deleteFtpFile($fileName, $ftp); catch { if (blessed($_) && $_->isa('Koha::Exception::ConnectionFailed')) { warn $_->error()."\n"; } }
I'm not sure that this is really necessary, although adding Net::FTP as a dependency could be useful. Maybe Koha::FTP plus a CLI tool? I do FTP files from Koha instances so it could be handy to have this built-in