From 7b7f88ae4f656e61c298652e78d151e72d70f897 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Wed, 5 Nov 2014 19:45:31 +0300 Subject: [PATCH] WebUI: Fix WebAPI returned data. --- src/webui/extra_translations.h | 3 ++- src/webui/requesthandler.cpp | 3 ++- src/webui/www/public/upload.html | 11 ++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/webui/extra_translations.h b/src/webui/extra_translations.h index bd9018ca4..840228afe 100644 --- a/src/webui/extra_translations.h +++ b/src/webui/extra_translations.h @@ -65,7 +65,8 @@ static const char *__TRANSLATIONS__[] = { QT_TRANSLATE_NOOP("HttpServer", "Invalid Username or Password."), QT_TRANSLATE_NOOP("HttpServer", "Password"), QT_TRANSLATE_NOOP("HttpServer", "Login"), - QT_TRANSLATE_NOOP("HttpServer", "qBittorrent web User Interface") + QT_TRANSLATE_NOOP("HttpServer", "qBittorrent web User Interface"), + QT_TRANSLATE_NOOP("HttpServer", "Upload Failed!") }; static const struct { const char *source; const char *comment; } __COMMENTED_TRANSLATIONS__[] = { diff --git a/src/webui/requesthandler.cpp b/src/webui/requesthandler.cpp index b53baf8bf..dc4bf0cc8 100644 --- a/src/webui/requesthandler.cpp +++ b/src/webui/requesthandler.cpp @@ -263,11 +263,12 @@ void RequestHandler::action_command_upload() QBtSession::instance()->addTorrent(filePath); // Clean up fsutils::forceRemove(filePath); - print(QLatin1String("")); } else { qWarning() << "I/O Error: Could not create temporary file"; + status(500, "Internal Server Error"); + print(QByteArray("I/O Error: Could not create temporary file."), CONTENT_TYPE_TXT); } } } diff --git a/src/webui/www/public/upload.html b/src/webui/www/public/upload.html index f00f48bfc..f7ded939d 100644 --- a/src/webui/www/public/upload.html +++ b/src/webui/www/public/upload.html @@ -9,10 +9,15 @@ function stateChangeHandler() { if (this.readyState == this.DONE) { - if (this.status == 200) + if (this.status == 200) { window.parent.closeWindows(); - else - alert("Upload Failed!"); + } else { + if (this.responseText != "") { + alert(this.responseText); + } else { + alert("_(Upload Failed!)"); + } + } } }