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. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
e7307ddc05
commit
7e576e58f8
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue