View | Details | Raw Unified | Return to bug 33308
Collapse All | Expand All

(-)a/misc/cronjobs/runreport.pl (-14 / +8 lines)
Lines 404-432 foreach my $report_id (@ARGV) { Link Here
404
    if ($sftp_dest_id) {
404
    if ($sftp_dest_id) {
405
        my $sftp_server = Koha::File::Transports->find($sftp_dest_id);
405
        my $sftp_server = Koha::File::Transports->find($sftp_dest_id);
406
406
407
        die("ERROR:\tSupplied FTP/SFTP Server doesn\'t exist")
407
        die("ERROR:\tSupplied FTP/SFTP Server doesn't exist")
408
            unless ($sftp_server);
408
            unless ($sftp_server);
409
409
410
        die("ERROR:\tUnable to connect to FTP/SFTP Server")
411
            unless ( $sftp_server->connect );
412
413
        my $upload_directory = $sftp_server->upload_directory;
410
        my $upload_directory = $sftp_server->upload_directory;
414
        my $content_type     = "text/$format";
411
        my $filename_to_use  = $filename || "report$report_id-$date.$format";
415
        my $filename         = $filename || "report$report_id-$date.$format";
416
412
417
        open my $fh, "<", \$message;
413
        open my $fh, "<", \$message;
418
414
        die("ERROR:\tMessage supplied is empty, or not suitable for upload")
419
        die("ERROR\tMessage supplied is empty, or, not suitable for upload")
420
            unless ($fh);
415
            unless ($fh);
421
416
422
        die("ERROR\tNo upload directory specified in config")
417
        die("ERROR:\tNo upload directory specified in config")
423
            unless ($upload_directory);
418
            unless ($upload_directory);
424
419
425
        die("ERROR\tUnable to change directory")
420
        # Use simplified API - automatic connection and directory management
426
            unless ( $sftp_server->change_directory($upload_directory) );
421
        my $result = $sftp_server->upload_file( $fh, $filename_to_use, { path => $upload_directory } );
427
422
428
        die("ERROR\tUnable to upload report to server")
423
        die("ERROR:\tUnable to upload report to server")
429
            unless ( $sftp_server->upload_file( $fh, $filename ) );
424
            unless ($result);
430
    }
425
    }
431
426
432
    if ( !$send_email && !$sftp_dest_id ) {
427
    if ( !$send_email && !$sftp_dest_id ) {
433
- 

Return to bug 33308