[Libreoffice-commits] online.git: 2 commits - loolwsd/ClientSession.hpp loolwsd/DocumentBroker.cpp

Pranav Kant pranavk at collabora.co.uk
Tue Nov 22 17:42:50 UTC 2016


 loolwsd/ClientSession.hpp  |    1 +
 loolwsd/DocumentBroker.cpp |   22 +++++++++++++++++++---
 2 files changed, 20 insertions(+), 3 deletions(-)

New commits:
commit 6debf76cd305c2174410105442e0b05d9b16f999
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Nov 22 23:10:10 2016 +0530

    loolwsd: Use document owner always, if available, to autosave
    
    Change-Id: I826cbac642579261ca76d7cc5602c5d39a1587cb

diff --git a/loolwsd/ClientSession.hpp b/loolwsd/ClientSession.hpp
index 7b7740c..5349caa 100644
--- a/loolwsd/ClientSession.hpp
+++ b/loolwsd/ClientSession.hpp
@@ -41,6 +41,7 @@ public:
     void setUserId(const std::string& userId) { _userId = userId; }
     void setUserName(const std::string& userName) { _userName = userName; }
     void setDocumentOwner(const bool isDocumentOwner) { _isDocumentOwner = isDocumentOwner; }
+    bool isDocumentOwner() const { return _isDocumentOwner; }
 
     /**
      * Return the URL of the saved-as document when it's ready. If called
diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 4b83ec4..949cec5 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -448,9 +448,25 @@ bool DocumentBroker::sendUnoSave(const bool dontSaveIfUnmodified)
     LOG_INF("Autosave triggered for doc [" << _docKey << "].");
     Util::assertIsLocked(_mutex);
 
-    // Save using session holding the edit-lock (or first if multview).
+    std::shared_ptr<ClientSession> savingSession;
     for (auto& sessionIt : _sessions)
     {
+        // Save the document using first session available ...
+        if (!savingSession)
+        {
+            savingSession = sessionIt.second;
+        }
+
+        // or if any of the sessions is document owner, use that.
+        if (sessionIt.second->isDocumentOwner())
+        {
+            savingSession = sessionIt.second;
+            break;
+        }
+    }
+
+    if (savingSession)
+    {
         // Invalidate the timestamp to force persisting.
         _lastFileModifiedTime.fromEpochTime(0);
 
@@ -484,7 +500,7 @@ bool DocumentBroker::sendUnoSave(const bool dontSaveIfUnmodified)
         const auto saveArgs = oss.str();
         LOG_TRC(".uno:Save arguments: " << saveArgs);
         const auto command = "uno .uno:Save " + saveArgs;
-        forwardToChild(sessionIt.second->getId(), command);
+        forwardToChild(savingSession->getId(), command);
         return true;
     }
 
commit c06c0f83c25819ba4d65ac1b690b4c9f0d04422e
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Nov 22 23:08:40 2016 +0530

    loolwsd: Set document owners unconditionally
    
    Change-Id: I99b1ff4c30700a93a32f1a944704aee2b4b08ca8

diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 74dada2..4b83ec4 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -276,7 +276,7 @@ bool DocumentBroker::load(std::shared_ptr<ClientSession>& session, const std::st
         session->sendTextFrame("wopi: " + ossWopiInfo.str());
 
         // Mark the session as 'Document owner' if WOPI hosts supports it
-        if (wopifileinfo._enableOwnerTermination && userid == _storage->getFileInfo()._ownerId)
+        if (userid == _storage->getFileInfo()._ownerId)
         {
             LOG_DBG("Session [" + sessionId + "] is the document owner");
             session->setDocumentOwner(true);


More information about the Libreoffice-commits mailing list