[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - kit/ChildSession.cpp test/UnitWOPISaveAs.cpp test/WopiTestServer.hpp wsd/ClientSession.cpp wsd/Storage.cpp
Jan Holesovsky
kendy at collabora.com
Mon Nov 6 13:00:53 UTC 2017
kit/ChildSession.cpp | 8 ++++++++
test/UnitWOPISaveAs.cpp | 10 +++++++---
test/WopiTestServer.hpp | 2 +-
wsd/ClientSession.cpp | 1 +
wsd/Storage.cpp | 7 ++++---
5 files changed, 21 insertions(+), 7 deletions(-)
New commits:
commit 4b39cd80f531391ac1cc7a124a282f1596025d2d
Author: Jan Holesovsky <kendy at collabora.com>
Date: Mon Nov 6 12:44:37 2017 +0100
Save As: Advertise the correct size when uploading the new file.
Change-Id: I9b20c4bdb7ddc848437edceae1a77ddb49d55133
Reviewed-on: https://gerrit.libreoffice.org/44357
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index d7db56b4..ec439918 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -610,6 +610,10 @@ bool ChildSession::downloadAs(const char* /*buffer*/, int /*length*/, const std:
{
std::unique_lock<std::mutex> lock(_docManager.getDocumentMutex());
+ LOG_DBG("Calling LOK's downloadAs with: '" << url.c_str() << "', '" <<
+ (format.size() == 0 ? "(nullptr)" : format.c_str()) << "', '" <<
+ (filterOptions.size() == 0 ? "(nullptr)" : filterOptions.c_str()) << "'.");
+
getLOKitDocument()->saveAs(url.c_str(),
format.size() == 0 ? nullptr :format.c_str(),
filterOptions.size() == 0 ? nullptr : filterOptions.c_str());
@@ -936,6 +940,10 @@ bool ChildSession::saveAs(const char* /*buffer*/, int /*length*/, const std::vec
getLOKitDocument()->setView(_viewId);
+ LOG_DBG("Calling LOK's saveAs with: '" << url.c_str() << "', '" <<
+ (format.size() == 0 ? "(nullptr)" : format.c_str()) << "', '" <<
+ (filterOptions.size() == 0 ? "(nullptr)" : filterOptions.c_str()) << "'.");
+
success = getLOKitDocument()->saveAs(url.c_str(),
format.size() == 0 ? nullptr :format.c_str(),
filterOptions.size() == 0 ? nullptr : filterOptions.c_str());
diff --git a/test/UnitWOPISaveAs.cpp b/test/UnitWOPISaveAs.cpp
index d981c551..578ec37f 100644
--- a/test/UnitWOPISaveAs.cpp
+++ b/test/UnitWOPISaveAs.cpp
@@ -34,13 +34,17 @@ public:
void assertPutRelativeFileRequest(const Poco::Net::HTTPRequest& request) override
{
// spec says UTF-7...
- CPPUNIT_ASSERT_EQUAL(std::string("/jan/hole+AWE-ovsk+AP0-/hello world.txt"), request.get("X-WOPI-SuggestedTarget"));
+ CPPUNIT_ASSERT_EQUAL(std::string("/jan/hole+AWE-ovsk+AP0-/hello world.pdf"), request.get("X-WOPI-SuggestedTarget"));
+
+ // make sure it is a pdf - or at least that it is larger than what it
+ // used to be
+ CPPUNIT_ASSERT(std::stoul(request.get("X-WOPI-Size")) > _fileContent.size());
}
bool filterSendMessage(const char* data, const size_t len, const WSOpCode /* code */, const bool /* flush */, int& /*unitReturn*/) override
{
std::string message(data, len);
- if (message == "saveas: url=" + helpers::getTestServerURI() + "/something%20wopi/files/1?access_token=anything filename=hello%20world.txt")
+ if (message == "saveas: url=" + helpers::getTestServerURI() + "/something%20wopi/files/1?access_token=anything filename=hello%20world.pdf")
{
// successfully exit the test if we also got the outgoing message
// notifying about saving the file
@@ -61,7 +65,7 @@ public:
initWebsocket("/wopi/files/0?access_token=anything");
helpers::sendTextFrame(*_ws->getLOOLWebSocket(), "load url=" + _wopiSrc, testName);
- helpers::sendTextFrame(*_ws->getLOOLWebSocket(), "saveas url=wopi:///jan/hole%C5%A1ovsk%C3%BD/hello%20world.txt", testName);
+ helpers::sendTextFrame(*_ws->getLOOLWebSocket(), "saveas url=wopi:///jan/hole%C5%A1ovsk%C3%BD/hello%20world.pdf", testName);
SocketPoll::wakeupWorld();
_phase = Phase::Polling;
diff --git a/test/WopiTestServer.hpp b/test/WopiTestServer.hpp
index 4f0e14c6..b20aa032 100644
--- a/test/WopiTestServer.hpp
+++ b/test/WopiTestServer.hpp
@@ -147,7 +147,7 @@ protected:
assertPutRelativeFileRequest(request);
std::string wopiURL = helpers::getTestServerURI() + "/something wopi/files/1?access_token=anything";
- std::string content = "{ \"Name\":\"hello world.txt\", \"Url\":\"" + wopiURL + "\" }";
+ std::string content = "{ \"Name\":\"hello world.pdf\", \"Url\":\"" + wopiURL + "\" }";
std::ostringstream oss;
oss << "HTTP/1.1 200 OK\r\n"
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 60364a2a..adb2a0ac 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -675,6 +675,7 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt
if (resultURL.getScheme() == "file" && !resultURL.getPath().empty())
{
// this also sends the saveas: result
+ LOG_TRC("Save-as path: " << resultURL.getPath());
docBroker->saveAsToStorage(getId(), resultURL.getPath(), wopiFilename);
}
else
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 05f3b945..54c8a207 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -663,15 +663,17 @@ std::string WopiStorage::loadStorageFileToLocal(const Authorization& auth)
StorageBase::SaveResult WopiStorage::saveLocalFileToStorage(const Authorization& auth, const std::string& saveAsPath, const std::string& saveAsFilename)
{
// TODO: Check if this URI has write permission (canWrite = true)
- const auto size = getFileSize(_jailedFilePath);
const bool isSaveAs = !saveAsPath.empty() && !saveAsFilename.empty();
+ const std::string filePath(isSaveAs? saveAsPath: _jailedFilePath);
+
+ const auto size = getFileSize(filePath);
Poco::URI uriObject(_uri);
uriObject.setPath(isSaveAs? uriObject.getPath(): uriObject.getPath() + "/contents");
auth.authorizeURI(uriObject);
- LOG_INF("Uploading URI via WOPI [" << uriObject.toString() << "] from [" << _jailedFilePath + "].");
+ LOG_INF("Uploading URI via WOPI [" << uriObject.toString() << "] from [" << filePath + "].");
std::ostringstream oss;
StorageBase::SaveResult saveResult(StorageBase::SaveResult::FAILED);
@@ -740,7 +742,6 @@ StorageBase::SaveResult WopiStorage::saveLocalFileToStorage(const Authorization&
addStorageDebugCookie(request);
std::ostream& os = psession->sendRequest(request);
- const std::string filePath(isSaveAs? saveAsPath: _jailedFilePath);
std::ifstream ifs(filePath);
Poco::StreamCopier::copyStream(ifs, os);
More information about the Libreoffice-commits
mailing list