wsd: logging and cosmetics

Change-Id: I777db7d1879e84f341f11a90fce7abf8241f5ced
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
pull/7942/head
Ashod Nakashian 2024-01-03 19:23:19 -05:00 committed by Ashod Nakashian
parent b5d6ed1ea6
commit 7f2f946aec
3 changed files with 32 additions and 18 deletions

View File

@ -19,11 +19,7 @@
#include <Poco/Net/HTTPRequest.h>
#include "Util.hpp"
#include "Log.hpp"
#include "Unit.hpp"
#include "UnitHTTP.hpp"
#include "helpers.hpp"
#include "lokassert.hpp"
class UnitWOPISaveOnExit : public WOPIUploadConflictCommon
@ -213,7 +209,7 @@ public:
/// The document is loaded.
bool onDocumentLoaded(const std::string& message) override
{
LOG_TST("onDocumentLoaded: [" << message << ']');
LOG_TST("Got: [" << message << ']');
LOK_ASSERT_STATE(_phase, Phase::WaitLoadStatus);
LOG_TST("Modifying the document");
@ -228,7 +224,7 @@ public:
bool onDocumentModified(const std::string& message) override
{
LOG_TST("onDocumentModified: [" << message << ']');
LOG_TST("Got: [" << message << ']');
LOK_ASSERT_STATE(_phase, Phase::WaitModifiedStatus);
TRANSITION_STATE(_phase, Phase::WaitUploadAfterSave);
@ -322,14 +318,14 @@ class UnitSaveOnExitUnmodified : public WopiTestServer
public:
UnitSaveOnExitUnmodified()
: WopiTestServer("UnitSaveOnExitUnmodified")
: Base("UnitSaveOnExitUnmodified")
, _phase(Phase::Load)
{
}
void configure(Poco::Util::LayeredConfiguration& config) override
{
WopiTestServer::configure(config);
Base::configure(config);
// Make it more likely to force uploading.
config.setBool("per_document.always_save_on_exit", true);
@ -347,7 +343,7 @@ public:
/// The document is loaded.
bool onDocumentLoaded(const std::string& message) override
{
LOG_TST("onDocumentLoaded: [" << message << ']');
LOG_TST("Got: [" << message << ']');
LOK_ASSERT_STATE(_phase, Phase::WaitLoadStatus);
TRANSITION_STATE(_phase, Phase::WaitDestroy);

View File

@ -1442,6 +1442,9 @@ void DocumentBroker::handleSaveResponse(const std::shared_ptr<ClientSession>& se
{
ASSERT_CORRECT_THREAD();
// When dontSaveIfUnmodified=true, there is a shortcut in LOKit
// that shortcuts saving when the document is not modified.
// In that case, success=false and result=unmodified.
const bool success = json->get("success").toString() == "true";
std::string result;
if (json->has("result"))
@ -1452,6 +1455,12 @@ void DocumentBroker::handleSaveResponse(const std::shared_ptr<ClientSession>& se
result = resultObj->get("value").toString();
}
// wasModified is only set when LOKit saves the document.
// If the document was modified before saving, it would
// be true. Otherwise, it's false. Meaningful when forced
// saving (i.e. dontSaveIfUnmodified=false), otherwise
// result is blank in that case and we can't know if
// the document saved was modified or not.
if (json->has("wasModified"))
{
// If Core reports the modified state before saving,
@ -1499,12 +1508,12 @@ void DocumentBroker::handleSaveResponse(const std::shared_ptr<ClientSession>& se
const auto onrre = errno;
if (success || onrre != ENOENT)
LOG_ERR("Failed to rename [" << oldName << "] to [" << newName << "] ("
<< Util::symbolicErrno(onrre) << ": "
<< std::strerror(onrre) << ')');
<< Util::symbolicErrno(onrre) << ": "
<< std::strerror(onrre) << ')');
else
LOG_DBG("Failed to rename [" << oldName << "] to [" << newName << "] ("
<< Util::symbolicErrno(onrre) << ": "
<< std::strerror(onrre) << ')');
<< Util::symbolicErrno(onrre) << ": "
<< std::strerror(onrre) << ')');
}
else
{
@ -1539,7 +1548,7 @@ void DocumentBroker::checkAndUploadToStorage(const std::shared_ptr<ClientSession
const NeedToUpload needToUploadState = needToUploadToStorage();
LOG_TRC("checkAndUploadToStorage with session ["
<< session->getId() << "], justSaved: " << justSaved
<< sessionId << "], justSaved: " << justSaved
<< ", activity: " << DocumentState::name(_docState.activity())
<< ", needToUpload: " << name(needToUploadState));

View File

@ -1012,12 +1012,21 @@ private:
/// Sets whether the last save was successful or not.
void setLastSaveResult(bool success, bool newVersion)
{
LOG_DBG("Saving version #" << version() + 1 << (success ? " succeeded" : " failed")
<< " after " << _request.timeSinceLastRequest());
_request.setLastRequestResult(success);
if (newVersion)
{
++_version; // Bump the version.
LOG_DBG("Saving of new version #"
<< _version << (success ? " succeeded" : " failed") << " after "
<< _request.timeSinceLastRequest());
}
else
{
LOG_DBG("Saving" << (success ? " succeeded" : " failed") << " after "
<< _request.timeSinceLastRequest()
<< " but no newer version than #" << _version << " is produced");
}
_request.setLastRequestResult(success);
}
/// Returns the last save request time.