Bugzilla – Attachment 190463 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
ebfed0b.patch (text/plain), 2.90 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-12-12 13:13:25 UTC
(
hide
)
Description:
Bug 33308: (QA follow-up) Use simplified File::Transport API from bug 40811
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-12-12 13:13:25 UTC
Size:
2.90 KB
patch
obsolete
>From ebfed0b76a5c92cedbc44fda5ef3b7981f77f20e 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 >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >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> >Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> >--- > 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 39b372dcce..b7f048cf87 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.50.1 (Apple Git-155) >
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