From 3575439519c139d698ab6a452d88946640a3f54c Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 19 Oct 2017 10:39:23 +0000 Subject: [PATCH] Bug 19420: Improve display of errors from failure of uploading file during stage import Content-Type: text/plain; charset=utf-8 To test: 1 - sudo chown www-data:www-data /tmp/koha_kohadev_upload/ (or your relevant dir and user) 2 - Attempt to stage a file 3 - Error message is: Upload status: Failed 4 - Apply patch 5 - Repeat upload 6 - Error is now: Failed - Directory is not writeable: /tmp/koha_kohadev_upload 7 - Trigger the other errors if you can and note better responses Signed-off-by: Katrin Fischer Signed-off-by: Marcel de Rooy --- Koha/Uploader.pm | 2 +- koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Koha/Uploader.pm b/Koha/Uploader.pm index 844c166..7a02d11 100644 --- a/Koha/Uploader.pm +++ b/Koha/Uploader.pm @@ -153,7 +153,7 @@ sub err { my $err; foreach my $f ( keys %{ $self->{files} } ) { my $e = $self->{files}->{$f}->{errcode}; - $err->{ $f } = $e if $e; + $err->{ $f }->{code} = $e if $e; } return $err; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt index 3229ea6..c95c88e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt @@ -59,7 +59,7 @@ function CancelUpload() { $("#fileuploadfailed").show(); $("#fileuploadfailed").text( _("Upload status: Cancelled ") ); } -function cbUpload( status, fileid ) { +function cbUpload( status, fileid, errors ) { if( status=='done' ) { $("#uploadedfileid").val( fileid ); $('#fileToUpload').prop('disabled',true); @@ -72,12 +72,14 @@ function cbUpload( status, fileid ) { } $("#processfile").show(); } else { + var errMsgs = [ _("File already exists"), _("Directory is not writeable"), _("Root directory for uploads not defined"), _("Temporary directory for uploads not defined") ]; + var errCode = errors[$('#fileToUpload').prop('files')[0].name].code; $('#fileuploadbutton').show(); $("#fileuploadcancel").hide(); $("#fileuploadstatus").hide(); $("#fileuploadfailed").show(); $("#fileuploadfailed").text( _("Upload status: ") + - ( status=='failed'? _("Failed"): + ( status=='failed'? _("Failed") + " - (" + errCode + ") " + errMsgs[errCode]: ( status=='denied'? _("Denied"): status )) ); } -- 2.1.4