View | Details | Raw Unified | Return to bug 14893
Collapse All | Expand All

(-)a/Koha/Upload.pm (-2 / +7 lines)
Lines 252-259 sub _init { Link Here
252
252
253
    $params->{tmp} = $params->{temp} if !exists $params->{tmp};
253
    $params->{tmp} = $params->{temp} if !exists $params->{tmp};
254
    $self->{temporary} = $params->{tmp}? 1: 0; #default false
254
    $self->{temporary} = $params->{tmp}? 1: 0; #default false
255
    $self->{category} = $params->{tmp}? KOHA_UPLOAD:
255
    if( $params->{tmp} ) {
256
        ( $params->{category} || KOHA_UPLOAD );
256
        my $db =  C4::Context->config('database');
257
        $self->{category} = KOHA_UPLOAD;
258
        $self->{category} =~ s/koha/$db/;
259
    } else {
260
        $self->{category} = $params->{category} || KOHA_UPLOAD;
261
    }
257
262
258
    $self->{files} = {};
263
    $self->{files} = {};
259
    $self->{uid} = C4::Context->userenv->{number} if C4::Context->userenv;
264
    $self->{uid} = C4::Context->userenv->{number} if C4::Context->userenv;
(-)a/installer/data/mysql/atomicupdate/14893_cleanup.perl (+16 lines)
Line 0 Link Here
1
# This perl snippet is run from within updatedatabase.pl
2
# Remove all temporary files from the obsolete koha_upload
3
# Bug 14893 replaces /tmp/koha_upload by /tmp/[db_name]_upload
4
# Permanent storage is not affected
5
6
use File::Path qw[remove_tree]; # perl core module
7
use File::Spec;
8
9
my $dbh= C4::Context->dbh;
10
$dbh->do(q|
11
    DELETE FROM uploaded_files
12
    WHERE COALESCE(permanent,0)=0 AND dir='koha_upload'
13
|);
14
15
my $tmp= File::Spec->tmpdir.'/koha_upload';
16
remove_tree( $tmp ) if -d $tmp;
(-)a/t/db_dependent/Upload.t (-2 / +1 lines)
Lines 125-131 sub test03 { Link Here
125
    my $cgi= $upl->cgi;
125
    my $cgi= $upl->cgi;
126
    is( $upl->count, 1, 'Upload 3 includes one temporary file' );
126
    is( $upl->count, 1, 'Upload 3 includes one temporary file' );
127
    my $r = $upl->get({ id => $upl->result });
127
    my $r = $upl->get({ id => $upl->result });
128
    is( $r->{uploadcategorycode}, 'koha_upload', 'Check category temp file' );
128
    is( $r->{uploadcategorycode} =~ /_upload$/, 1, 'Check category temp file' );
129
}
129
}
130
130
131
sub test04 { # Fail on a file already there
131
sub test04 { # Fail on a file already there
132
- 

Return to bug 14893