From 8f982fb657d2a9697ef59951914b84ca70c01617 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 17 Oct 2025 15:43:52 +0100 Subject: [PATCH] Bug 38115: (follow-up) Use File::Basename to extract filename for remote upload When --filename contains a path (e.g., /tmp/records.mrc), the script was uploading to the remote server with the full path, creating unwanted directory structures (e.g., uploads/tmp/records.mrc). This patch uses File::Basename::fileparse() to extract just the filename portion for the remote upload, while still using the full path for local file operations. --- misc/export_records.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/misc/export_records.pl b/misc/export_records.pl index 0a00f961640..fefa1667917 100755 --- a/misc/export_records.pl +++ b/misc/export_records.pl @@ -21,6 +21,7 @@ use MARC::File::XML; use List::MoreUtils qw( uniq ); use Getopt::Long qw( GetOptions ); use Pod::Usage qw( pod2usage ); +use File::Basename qw( fileparse ); use Koha::Script; use C4::Auth; @@ -384,7 +385,9 @@ if ($file_transport) { } # Upload the file - unless ( $file_transport->upload_file( $filename, $filename ) ) { + # Extract just the filename from the path for remote upload + my ($remote_filename) = fileparse($filename); + unless ( $file_transport->upload_file( $filename, $remote_filename ) ) { $file_transport->disconnect; die sprintf( "Error: Unable to upload file '%s' to server (ID: %s)\n", $filename, $destination_server_id ); } -- 2.51.0