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

Ashod Nakashian ashod.nakashian at collabora.co.uk
Fri Apr 29 01:07:17 UTC 2016


 loolwsd/DocumentBroker.cpp |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 2efaa6e06b212740abcb89ce26ad9ab8d585d204
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Wed Apr 27 20:52:32 2016 -0400

    loolwsd: save documents when timestamp is within 10 seconds
    
    Due to filesystem timestamp precision and other factors
    we assume a timestamp match within 10 seconds to mean
    the document has been recently saved and store it.
    
    A document has to have an older than 10 seconds
    modified timestamp compared to our last timestamp
    to be deemed unchanged in the interim and skipped
    from storing again.
    
    Change-Id: I39b4bf64b221ba30dc7b818a330e779a2d0ecbd4
    Reviewed-on: https://gerrit.libreoffice.org/24472
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 69728cb..ac1ed91 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -152,8 +152,11 @@ bool DocumentBroker::save()
     std::unique_lock<std::mutex> lock(_saveMutex);
 
     const auto uri = _uriPublic.toString();
+
+    // If the file hasn't been modified within the past 10 seconds, skip saving.
     const auto newFileModifiedTime = Poco::File(_storage->getLocalRootPath()).getLastModified();
-    if (newFileModifiedTime == _lastFileModifiedTime)
+    const auto elapsed = newFileModifiedTime - _lastFileModifiedTime;
+    if (std::abs(elapsed) > 10 * 1000 * 1000)
     {
         // Nothing to do.
         Log::debug("Skipping unnecessary saving to URI [" + uri + "].");


More information about the Libreoffice-commits mailing list