From 712410496e4e59fe1ee1968a94eeb73b51223996 Mon Sep 17 00:00:00 2001
From: Alexander Tkachev
Date: Fri, 29 Jul 2016 12:22:42 +0600
Subject: CLOUD: Fix UploadFileClientHandler
It now redirects user on success not only when file was the last field
in the content, but also when it was uploaded already and Handler worked
further to search for more files.
---
.../networking/sdl_net/uploadfileclienthandler.cpp | 32 ++++++++++++----------
.../networking/sdl_net/uploadfileclienthandler.h | 1 +
2 files changed, 19 insertions(+), 14 deletions(-)
(limited to 'backends')
diff --git a/backends/networking/sdl_net/uploadfileclienthandler.cpp b/backends/networking/sdl_net/uploadfileclienthandler.cpp
index e2832bcba5..ee02915d6f 100644
--- a/backends/networking/sdl_net/uploadfileclienthandler.cpp
+++ b/backends/networking/sdl_net/uploadfileclienthandler.cpp
@@ -167,18 +167,7 @@ void UploadFileClientHandler::handleBlockContent(Client *client) {
if (client->noMoreContent()) {
// success - redirect back to directory listing
- HandlerUtils::setMessageHandler(
- *client,
- Common::String::format(
- "%s
%s",
- _("Uploaded successfully!"),
- client->queryParameter("path").c_str(),
- _("Back to parent directory")
- ),
- (client->queryParameter("ajax") == "true" ? "/filesAJAX?path=" : "/files?path=") +
- LocalWebserver::urlEncodeQueryParameterValue(client->queryParameter("path"))
- );
- _state = UFH_STOP;
+ setSuccessHandler(*client);
return;
}
}
@@ -189,9 +178,8 @@ void UploadFileClientHandler::handleBlockContent(Client *client) {
if (_uploadedFiles == 0) {
setErrorMessageHandler(*client, _("No file was passed!"));
} else {
- _state = UFH_STOP;
+ setSuccessHandler(*client);
}
- return;
}
}
@@ -200,4 +188,20 @@ void UploadFileClientHandler::setErrorMessageHandler(Client &client, Common::Str
_state = UFH_ERROR;
}
+void UploadFileClientHandler::setSuccessHandler(Client &client) {
+ // success - redirect back to directory listing
+ HandlerUtils::setMessageHandler(
+ client,
+ Common::String::format(
+ "%s
%s",
+ _("Uploaded successfully!"),
+ client.queryParameter("path").c_str(),
+ _("Back to parent directory")
+ ),
+ (client.queryParameter("ajax") == "true" ? "/filesAJAX?path=" : "/files?path=") +
+ LocalWebserver::urlEncodeQueryParameterValue(client.queryParameter("path"))
+ );
+ _state = UFH_STOP;
+}
+
} // End of namespace Networking
diff --git a/backends/networking/sdl_net/uploadfileclienthandler.h b/backends/networking/sdl_net/uploadfileclienthandler.h
index 4aa6929888..b6481cf18f 100644
--- a/backends/networking/sdl_net/uploadfileclienthandler.h
+++ b/backends/networking/sdl_net/uploadfileclienthandler.h
@@ -56,6 +56,7 @@ class UploadFileClientHandler: public ClientHandler {
void handleBlockHeaders(Client *client);
void handleBlockContent(Client *client);
void setErrorMessageHandler(Client &client, Common::String message);
+ void setSuccessHandler(Client &client);
public:
UploadFileClientHandler(Common::String parentDirectoryPath);
--
cgit v1.2.3