[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-0' - wsd/DocumentBroker.cpp wsd/Storage.cpp wsd/Storage.hpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Thu Mar 23 09:36:50 UTC 2017


 wsd/DocumentBroker.cpp |    6 ++++--
 wsd/Storage.cpp        |    4 +---
 wsd/Storage.hpp        |    9 +++++++--
 3 files changed, 12 insertions(+), 7 deletions(-)

New commits:
commit 8962addd234c3574148858d3b181f4ed91f2ca0b
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Tue Mar 21 22:56:16 2017 -0400

    wsd: fix saving of modified documents
    
    Detection of modified documents used the
    directory path rather than the document
    path, which obviously wasn't correct.
    
    Reviewed-on: https://gerrit.libreoffice.org/35526
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    (cherry picked from commit 0314f8751c76482216f8f7fe842c2f615e8526d6)
    
    Change-Id: I4a054a9ce2b64d70cd7a0a1c488dcc38ef46a581
    Reviewed-on: https://gerrit.libreoffice.org/35550
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 96ec5113..423474e1 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -324,7 +324,7 @@ bool DocumentBroker::load(std::shared_ptr<ClientSession>& session, const std::st
         _filename = fileInfo._filename;
 
         // Use the local temp file's timestamp.
-        _lastFileModifiedTime = Poco::File(_storage->getLocalRootPath()).getLastModified();
+        _lastFileModifiedTime = Poco::File(_storage->getRootFilePath()).getLastModified();
         _tileCache.reset(new TileCache(_uriPublic.toString(), _lastFileModifiedTime, _cacheRoot));
     }
 
@@ -359,6 +359,8 @@ bool DocumentBroker::save(const std::string& sessionId, bool success, const std:
 
     // If save requested, but core didn't save because document was unmodified
     // notify the waiting thread, if any.
+    LOG_TRC("Saving to storage docKey [" << _docKey << "] for session [" << sessionId <<
+            "]. Success: " << success << ", result: " << result);
     if (!success && result == "unmodified")
     {
         LOG_DBG("Save skipped as document was not modified");
@@ -368,7 +370,7 @@ bool DocumentBroker::save(const std::string& sessionId, bool success, const std:
 
     // If we aren't destroying the last editable session just yet, and the file
     // timestamp hasn't changed, skip saving.
-    const auto newFileModifiedTime = Poco::File(_storage->getLocalRootPath()).getLastModified();
+    const auto newFileModifiedTime = Poco::File(_storage->getRootFilePath()).getLastModified();
     if (!_lastEditableSession && newFileModifiedTime == _lastFileModifiedTime)
     {
         // Nothing to do.
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 585711f1..d4426d72 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -207,11 +207,9 @@ std::unique_ptr<LocalStorage::LocalFileInfo> LocalStorage::getLocalFileInfo(cons
 
 std::string LocalStorage::loadStorageFileToLocal()
 {
-    const auto rootPath = getLocalRootPath();
-
     // /chroot/jailId/user/doc/childId/file.ext
     const auto filename = Poco::Path(_uri.getPath()).getFileName();
-    _jailedFilePath = Poco::Path(rootPath, filename).toString();
+    _jailedFilePath = Poco::Path(getLocalRootPath(), filename).toString();
     LOG_INF("Public URI [" << _uri.getPath() <<
             "] jailed to [" + _jailedFilePath + "].");
 
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index 58d7ecb3..053332fc 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -73,10 +73,11 @@ public:
         Log::debug("Storage ctor: " + uri.toString());
     }
 
-    std::string getLocalRootPath() const;
-
     const std::string getUri() const { return _uri.toString(); }
 
+    /// Returns the root path to the jailed file.
+    const std::string& getRootFilePath() const { return _jailedFilePath; };
+
     bool isLoaded() const { return _isLoaded; }
 
     /// Returns the basic information about the file.
@@ -98,6 +99,10 @@ public:
     static std::unique_ptr<StorageBase> create(const Poco::URI& uri,
                                                const std::string& jailRoot,
                                                const std::string& jailPath);
+protected:
+
+    /// Returns the root path of the jail directory of docs.
+    std::string getLocalRootPath() const;
 
 protected:
     const Poco::URI _uri;


More information about the Libreoffice-commits mailing list