wsd/ClientSession.cpp  |    6 ++++++
 wsd/DocumentBroker.cpp |    3 +++
 wsd/DocumentBroker.hpp |    5 +++++
 3 files changed, 14 insertions(+)

New commits:
commit 494a5221f5bb959f2cce19bc3dd662ac22027e0c
Author:     Samuel Mehrbrodt <samuel.mehrbr...@cib.de>
AuthorDate: Wed Aug 5 12:41:57 2020 +0200
Commit:     Samuel Mehrbrodt <samuel.mehrbr...@cib.de>
CommitDate: Thu Aug 13 09:39:30 2020 +0200

    Don't update modified status after saving to storage fails
    
    Otherwise client gets a notification that document is unmodified.
    This should not happen, as the document in the storage has not been updated
    and so it should be considered as modified until saving to storage succeeds.
    
    Change-Id: I6918f97d96a546ce086f622854f4cbeed48d54ae
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100162
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de>

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index a3fa8e078..0ed783f72 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -1317,6 +1317,12 @@ bool ClientSession::handleKitToClientMessage(const char* 
buffer, const int lengt
         StringVector stateTokens(Util::tokenize(tokens[1], '='));
         if (stateTokens.size() == 2 && stateTokens.equals(0, 
".uno:ModifiedStatus"))
         {
+            // When the document is saved internally, but saving to storage 
failed,
+            // don't update the client's modified status
+            // (otherwise client thinks document is unmodified b/c saving was 
successful)
+            if (!docBroker->isLastStorageSaveSuccessful())
+                return false;
+
             docBroker->setModified(stateTokens.equals(1, "true"));
         }
         else
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index a5e62fcc4..f89ed6953 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -176,6 +176,7 @@ DocumentBroker::DocumentBroker(ChildType type,
     _docKey(docKey),
     _docId(Util::encodeId(DocBrokerId++, 3)),
     _documentChangedInStorage(false),
+    _lastStorageSaveSuccessful(true),
     _lastSaveTime(std::chrono::steady_clock::now()),
     _lastSaveRequestTime(std::chrono::steady_clock::now() - 
std::chrono::milliseconds(COMMAND_TIMEOUT_MS)),
     _markToDestroy(false),
@@ -1049,6 +1050,7 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId, bool su
     assert(_storage && _tileCache);
     const StorageBase::SaveResult storageSaveResult = 
_storage->saveLocalFileToStorage(
         auth, it->second->getCookies(), *_lockCtx, saveAsPath, saveAsFilename, 
isRename);
+    _lastStorageSaveSuccessful = storageSaveResult.getResult() == 
StorageBase::SaveResult::OK;
     if (storageSaveResult.getResult() == StorageBase::SaveResult::OK)
     {
 #if !MOBILEAPP
@@ -2474,6 +2476,7 @@ void DocumentBroker::dumpState(std::ostream& os)
     os << "\n  last saved: " << Util::getSteadyClockAsString(_lastSaveTime);
     os << "\n  last save request: " << 
Util::getSteadyClockAsString(_lastSaveRequestTime);
     os << "\n  last save response: " << 
Util::getSteadyClockAsString(_lastSaveResponseTime);
+    os << "\n  last storage save was successful: " << 
isLastStorageSaveSuccessful();
     os << "\n  last modified: " << 
Util::getHttpTime(_documentLastModifiedTime);
     os << "\n  file last modified: " << 
Util::getHttpTime(_lastFileModifiedTime);
     if (_limitLifeSeconds)
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index b8e176b3c..e59a2d6b4 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -175,6 +175,8 @@ public:
 
     bool isDocumentChangedInStorage() { return _documentChangedInStorage; }
 
+    bool isLastStorageSaveSuccessful() { return _lastStorageSaveSuccessful; }
+
     /// Save the document to Storage if it needs persisting.
     bool saveToStorage(const std::string& sesionId, bool success, const 
std::string& result = "", bool force = false);
 
@@ -404,6 +406,9 @@ private:
     /// for user's command to act.
     bool _documentChangedInStorage;
 
+    /// Indicates whether the last saveToStorage operation was successful.
+    bool _lastStorageSaveSuccessful;
+
     /// The last time we tried saving, regardless of whether the
     /// document was modified and saved or not.
     std::chrono::steady_clock::time_point _lastSaveTime;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to