Skip to content

Commit

Permalink
Bug 29156: File missing warning in Koha::UploadedFile for permanent f…
Browse files Browse the repository at this point in the history
…iles only

When an uploaded file is deleted, when file does not exist there is a warning :
"Removing record for file.txt within category koha_upload, but file was missing."

For temporary files, this warning is noisy.
For example when they are in /tmp, system reboot deleted them.

I propose to remove this warning for temporary files.

Test plan :
1) Upload a temporary and a permanent file via Tools > Upload
2) Delete the file on server
3) Delete the two files from Tools > Upload
4) Look at warning in log files
=> You see only warning for permanent file

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
  • Loading branch information
fridobox committed Jan 22, 2022
1 parent 18e38b5 commit 474a19e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Koha/UploadedFile.pm
Expand Up @@ -78,8 +78,10 @@ sub delete {
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";
}
Expand Down

0 comments on commit 474a19e

Please sign in to comment.