@@ -, +, @@ instance in Upload.pm tools/upload.pl script without selecting a category). --- Koha/Upload.pm | 9 +++++++-- installer/data/mysql/atomicupdate/14893_cleanup.perl | 16 ++++++++++++++++ t/db_dependent/Upload.t | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/14893_cleanup.perl --- a/Koha/Upload.pm +++ a/Koha/Upload.pm @@ -252,8 +252,13 @@ sub _init { $params->{tmp} = $params->{temp} if !exists $params->{tmp}; $self->{temporary} = $params->{tmp}? 1: 0; #default false - $self->{category} = $params->{tmp}? KOHA_UPLOAD: - ( $params->{category} || KOHA_UPLOAD ); + if( $params->{tmp} ) { + my $db = C4::Context->config('database'); + $self->{category} = KOHA_UPLOAD; + $self->{category} =~ s/koha/$db/; + } else { + $self->{category} = $params->{category} || KOHA_UPLOAD; + } $self->{files} = {}; $self->{uid} = C4::Context->userenv->{number} if C4::Context->userenv; --- a/installer/data/mysql/atomicupdate/14893_cleanup.perl +++ a/installer/data/mysql/atomicupdate/14893_cleanup.perl @@ -0,0 +1,16 @@ +# This perl snippet is run from within updatedatabase.pl +# Remove all temporary files from the obsolete koha_upload +# Bug 14893 replaces /tmp/koha_upload by /tmp/[db_name]_upload +# Permanent storage is not affected + +use File::Path qw[remove_tree]; # perl core module +use File::Spec; + +my $dbh= C4::Context->dbh; +$dbh->do(q| + DELETE FROM uploaded_files + WHERE COALESCE(permanent,0)=0 AND dir='koha_upload' +|); + +my $tmp= File::Spec->tmpdir.'/koha_upload'; +remove_tree( $tmp ) if -d $tmp; --- a/t/db_dependent/Upload.t +++ a/t/db_dependent/Upload.t @@ -125,7 +125,7 @@ sub test03 { my $cgi= $upl->cgi; is( $upl->count, 1, 'Upload 3 includes one temporary file' ); my $r = $upl->get({ id => $upl->result }); - is( $r->{uploadcategorycode}, 'koha_upload', 'Check category temp file' ); + is( $r->{uploadcategorycode} =~ /_upload$/, 1, 'Check category temp file' ); } sub test04 { # Fail on a file already there --