Bug 14012

Summary: Koha::FTP, a happy FTP-library to supercharge FTP operations.
Product: Koha Reporter: Olli-Antti Kivilahti <olli-antti.kivilahti>
Component: Architecture, internals, and plumbingAssignee: Olli-Antti Kivilahti <olli-antti.kivilahti>
Status: In Discussion --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: dcook
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 13995    
Bug Blocks:    
Attachments: Bug 14012 - Koha::FTP, a happy FTP-library to supercharge FTP operations.

Description Olli-Antti Kivilahti 2015-04-19 14:46:37 UTC
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.
Comment 1 Olli-Antti Kivilahti 2015-04-19 14:48:42 UTC
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";
        }
    }
Comment 2 David Cook 2022-12-06 02:46:11 UTC
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