X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=Koha%2FUploadedFile.pm;h=13ec2eaadbceee1f16ae575212b93b2782bc459a;hb=c10aaa9d334c56bb01ca9034fbb6ac86559e1c30;hp=9df11786089a955110ea8fc2b746248cf764ff02;hpb=6d150eaeca5ba9c9fb3ef2229ce2138526b4db64;p=koha-ffzg.git diff --git a/Koha/UploadedFile.pm b/Koha/UploadedFile.pm index 9df1178608..13ec2eaadb 100644 --- a/Koha/UploadedFile.pm +++ b/Koha/UploadedFile.pm @@ -4,18 +4,18 @@ package Koha::UploadedFile; # # This file is part of Koha. # -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 3 of the License, or (at your option) any later -# version. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. # -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . use Modern::Perl; use File::Spec; @@ -75,18 +75,13 @@ sub delete { my $file = $self->full_path; my $retval = $self->SUPER::delete; - if( !defined($retval) ) { # undef is Unknown (-1) - $retval = -1; - } elsif( $retval eq '0' ) { # 0 => 0E0 - $retval = "0E0"; - } elsif( $retval !~ /^(0E0|1)$/ ) { # Unknown too - $retval = -1; - } return $retval if $params->{keep_file}; if( ! -e $file ) { - warn "Removing record for $name within category ". - $self->uploadcategorycode. ", but file was missing."; + if ( $self->permanent ) { + warn "Removing record for $name within category ". + $self->uploadcategorycode. ", but file was missing."; + } } elsif( ! unlink($file) ) { warn "Problem while deleting: $file"; } @@ -102,8 +97,9 @@ Returns the fully qualified path name for an uploaded file. sub full_path { my ( $self ) = @_; my $path = File::Spec->catfile( - $self->permanent? - $self->permanent_directory: $self->temporary_directory, + $self->permanent + ? $self->permanent_directory + : C4::Context->temporary_directory, $self->dir, $self->hashvalue. '_'. $self->filename, ); @@ -137,7 +133,7 @@ sub httpheaders { if( $self->filename =~ /\.pdf$/ ) { return ( '-type' => 'application/pdf', - 'Content-Disposition' => 'inline; filename='.$self->filename, + 'Content-Disposition' => 'inline; filename="'.$self->filename.'"', ); } else { return ( @@ -160,17 +156,6 @@ sub permanent_directory { return C4::Context->config('upload_path'); } -=head3 tmp_directory - -Returns root directory for temporary storage - -=cut - -sub temporary_directory { - my ( $class ) = @_; - return File::Spec->tmpdir; -} - =head3 _type Returns name of corresponding DBIC resultset