Bugzilla – Attachment 189910 Details for
Bug 33308
Add ability to to use SFTP with runreport.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33308: (QA follow-up) Use simplified File::Transport API from bug 40811
af944a8.patch (text/plain), 2.75 KB, created by
Martin Renvoize (ashimema)
on 2025-11-24 13:00:22 UTC
(
hide
)
Description:
Bug 33308: (QA follow-up) Use simplified File::Transport API from bug 40811
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-11-24 13:00:22 UTC
Size:
2.75 KB
patch
obsolete
>From af944a813d6e22927c7c73892b717d51646765c2 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Mon, 24 Nov 2025 12:58:58 +0000 >Subject: [PATCH] Bug 33308: (QA follow-up) Use simplified File::Transport API > from bug 40811 > >This follow-up updates runreport.pl to use the newer simplified >File::Transport API introduced by bug 40811, which provides: > >- Automatic connection management (no explicit connect/disconnect) >- Simplified directory handling via options hash >- Cleaner, more maintainable code > >The upload functionality now uses a single upload_file() call with >a path option instead of requiring separate connect() and >change_directory() calls. > >Also fixes minor inconsistencies in error messages (missing colons >and escaped quotes). > >Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> >--- > misc/cronjobs/runreport.pl | 21 ++++++++------------- > 1 file changed, 8 insertions(+), 13 deletions(-) > >diff --git a/misc/cronjobs/runreport.pl b/misc/cronjobs/runreport.pl >index 39b372dcce7..b7f048cf872 100755 >--- a/misc/cronjobs/runreport.pl >+++ b/misc/cronjobs/runreport.pl >@@ -404,29 +404,24 @@ foreach my $report_id (@ARGV) { > if ($sftp_dest_id) { > my $sftp_server = Koha::File::Transports->find($sftp_dest_id); > >- die("ERROR:\tSupplied FTP/SFTP Server doesn\'t exist") >+ die("ERROR:\tSupplied FTP/SFTP Server doesn't exist") > unless ($sftp_server); > >- die("ERROR:\tUnable to connect to FTP/SFTP Server") >- unless ( $sftp_server->connect ); >- > my $upload_directory = $sftp_server->upload_directory; >- my $content_type = "text/$format"; >- my $filename = $filename || "report$report_id-$date.$format"; >+ my $filename_to_use = $filename || "report$report_id-$date.$format"; > > open my $fh, "<", \$message; >- >- die("ERROR\tMessage supplied is empty, or, not suitable for upload") >+ die("ERROR:\tMessage supplied is empty, or not suitable for upload") > unless ($fh); > >- die("ERROR\tNo upload directory specified in config") >+ die("ERROR:\tNo upload directory specified in config") > unless ($upload_directory); > >- die("ERROR\tUnable to change directory") >- unless ( $sftp_server->change_directory($upload_directory) ); >+ # Use simplified API - automatic connection and directory management >+ my $result = $sftp_server->upload_file( $fh, $filename_to_use, { path => $upload_directory } ); > >- die("ERROR\tUnable to upload report to server") >- unless ( $sftp_server->upload_file( $fh, $filename ) ); >+ die("ERROR:\tUnable to upload report to server") >+ unless ($result); > } > > if ( !$send_email && !$sftp_dest_id ) { >-- >2.52.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33308
:
189005
|
189230
|
189909
|
189910
|
190462
|
190463