summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2024-04-18 19:51:04 +0100
committerCaolán McNamara <caolanm@gmail.com>2024-04-24 09:24:34 +0100
commit1516ca22cba24361a1342824046921fe9ec32b25 (patch)
treea7721536da6f2cb1d64fa2348fa09d73816e9cdc
parentbgsave: improve auto-save tests. (diff)
downloadonline-1516ca22cba24361a1342824046921fe9ec32b25.tar.gz
online-1516ca22cba24361a1342824046921fe9ec32b25.zip
bgsave: set state to unmodified on successful background save.
There is a race here, clearly if you type while a background save is ongoing - but this is far better than leaving the document apparently unmodified. Signed-off-by: Michael Meeks <michael.meeks@collabora.com> Change-Id: Ie5e3e692294e48ad887481af2e0906092830f265
-rw-r--r--kit/Kit.hpp2
-rw-r--r--kit/KitWebSocket.cpp29
2 files changed, 29 insertions, 2 deletions
diff --git a/kit/Kit.hpp b/kit/Kit.hpp
index e368847d95..d2c16d841d 100644
--- a/kit/Kit.hpp
+++ b/kit/Kit.hpp
@@ -383,13 +383,13 @@ public:
void dumpState(std::ostream& oss);
-private:
/// Return access to the lok::Office instance.
std::shared_ptr<lok::Office> getLOKit() override { return _loKit; }
/// Return access to the lok::Document instance.
std::shared_ptr<lok::Document> getLOKitDocument() override;
+private:
std::string getObfuscatedFileId() override { return _obfuscatedFileId; }
/// Stops theads, flushes buffers, and exits the process.
diff --git a/kit/KitWebSocket.cpp b/kit/KitWebSocket.cpp
index 5c1e31911e..cbf647856b 100644
--- a/kit/KitWebSocket.cpp
+++ b/kit/KitWebSocket.cpp
@@ -22,6 +22,7 @@
#include <sys/types.h>
#include <common/Seccomp.hpp>
+#include <common/JsonUtil.hpp>
#include <common/TraceEvent.hpp>
#include <common/MessageQueue.hpp>
@@ -232,11 +233,37 @@ void BgSaveParentWebSocketHandler::handleMessage(const std::vector<char>& data)
// FIXME: check for badness - jsdialogs and so on and bail ... ?
// Should pass only:
- // "error:", "asyncsave", "forcedtracevent", "unocommandresult"
+ // "error:", "asyncsave", "forcedtracevent", "unocommandresult:"
// "statusindicator[start|finish|setvalue]"
// Messages already include client-foo prefixes inherited from ourselves
_document->sendFrame(data.data(), data.size(), WSOpCode::Text);
+
+ // Status update messages are stuck in the bgsave's Idle CallbackFlushHandler
+ if (tokens[1] == "unocommandresult:")
+ {
+ std::string msg(data.data(), data.size());
+ Poco::JSON::Object::Ptr object;
+ if (JsonUtil::parseJSON(msg, object) &&
+ object->get("commandName").toString() == ".uno:Save")
+ {
+ if (object->get("success").toString() == "true")
+ {
+ // Force Modified state off, expecting a notification in a bit ...
+ LOG_TRC("Force modified state clear");
+ SigUtil::addActivity("Force clear modified");
+ _document->getLOKitDocument()->postUnoCommand(".uno:Modified", "{ \"Modified\": { \"type\": \"boolean\", \"value\": \"false\" } }", true);
+#if 0
+ // Synthesize modified status change
+ std::string modMsg = tokens[0] + " statechanged: .uno:ModifiedStatus=false";
+ LOG_TRC("Synthesize modified status clear");
+ _document->sendFrame(modMsg.c_str(), modMsg.size(), WSOpCode::Text);
+#endif
+ }
+ else
+ LOG_DBG("Failed to save, not synthesizing modified state");
+ }
+ }
}
void BgSaveParentWebSocketHandler::onDisconnect()