From 1f5be3ffabdf259f4c415634359aa682d6455c45 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 16 Sep 2015 13:53:38 +0200 Subject: [PATCH] Bug 14321: [QA Follow-up] Changes for Upload.pm and upload-file.pl Based on QA comments, this patch does the following: [1] Destroy an empty DESTROY. [2] Promote some comment lines to POD. [3] Use File::Spec->catfile in sub _full_fname. [4] Remove variable interpolation from a sql query. [5] Add a comment in upload-file.pl. Signed-off-by: Marcel de Rooy Run the unit test again, and uploaded a file. Signed-off-by: Julian Maurice Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi --- Koha/Upload.pm | 19 ++++++++++--------- tools/upload-file.pl | 3 ++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Koha/Upload.pm b/Koha/Upload.pm index 9b580ecc97..e8787fa55d 100644 --- a/Koha/Upload.pm +++ b/Koha/Upload.pm @@ -211,10 +211,7 @@ sub delete { return @res; } -sub DESTROY { -} - -# ************** HELPER ROUTINES / CLASS METHODS ****************************** +=head1 CLASS METHODS =head2 getCategories @@ -243,7 +240,9 @@ sub httpheaders { ); } -# ************** INTERNAL ROUTINES ******************************************** +=head1 INTERNAL ROUTINES + +=cut sub _init { my ( $self, $params ) = @_; @@ -310,9 +309,11 @@ sub _full_fname { my ( $self, $rec ) = @_; my $p; if( ref $rec ) { - $p= $rec->{permanent}? $self->{rootdir}: $self->{tmpdir}; - $p.= '/'; - $p.= $rec->{dir}. '/'. $rec->{hashvalue}. '_'. $rec->{filename}; + $p = File::Spec->catfile( + $rec->{permanent}? $self->{rootdir}: $self->{tmpdir}, + $rec->{dir}, + $rec->{hashvalue}. '_'. $rec->{filename} + ); } return $p; } @@ -359,7 +360,7 @@ sub _register { sub _lookup { my ( $self, $params ) = @_; my $dbh = C4::Context->dbh; - my $sql = qq| + my $sql = q| SELECT id,hashvalue,filename,dir,filesize,categorycode,public,permanent FROM uploaded_files |; diff --git a/tools/upload-file.pl b/tools/upload-file.pl index f54d6b1ee4..19942141b0 100755 --- a/tools/upload-file.pl +++ b/tools/upload-file.pl @@ -81,7 +81,8 @@ sub send_reply { # response will be sent back as JSON }); } -sub upload_pars { +sub upload_pars { # this sub parses QUERY_STRING in order to build the + # parameter hash for Koha::Upload my ( $qstr ) = @_; $qstr = Encode::decode_utf8( uri_unescape( $qstr ) ); # category could include a utf8 character -- 2.39.5