loolwsd/DocumentBroker.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
New commits: commit ca22a79034cbf996f788303633297c9c11096143 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Mon May 9 21:15:09 2016 -0400 loolwsd: simplify detection of file modification To avoid persisting the same document many times over we check the jailed file timestamp. This logic doesn't need to be more complex than simply invalidating the last timestamp upon issuing .uno:Save and setting it to the file's actual timestamp upon persisting. Change-Id: I4afdf8da93fed438d4cbcd6de8dc14d52172ac9c Reviewed-on: https://gerrit.libreoffice.org/24811 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp index 7b1af96..764c6ab 100644 --- a/loolwsd/DocumentBroker.cpp +++ b/loolwsd/DocumentBroker.cpp @@ -177,23 +177,16 @@ bool DocumentBroker::save() const auto uri = _uriPublic.toString(); - // If we aren't potentially destroying just yet, and the file has been - // modified within the past 10 seconds, skip saving. - // - // FIXME this is because currently the ChildProcessSession broadcasts the - // unocommandresult, so we get called several times here, and have no real - // possibility to distinguish who was the 1st caller. - // The refactor to un-thread the ChildProcessSession, and move the - // broadcasting up in the hierarchy (so that we can 'sniff' the - // unocommandresult for .uno:Save at the place where it appears just once) - // is planned post-release. + // If we aren't potentially destroying just yet, and the file + // timestamp hasn't changed, skip saving. const auto newFileModifiedTime = Poco::File(_storage->getLocalRootPath()).getLastModified(); - const auto elapsed = newFileModifiedTime - _lastFileModifiedTime; - if (!canDestroy() && std::abs(elapsed) < 10 * 1000) + if (!isMarkedToDestroy() && newFileModifiedTime == _lastFileModifiedTime) { // Nothing to do. Log::debug() << "Skipping unnecessary saving to URI [" << uri - << "]. File last modified " << elapsed << " ms ago." << Log::end; + << "]. File last modified " + << _lastFileModifiedTime.elapsed() / 1000000 + << " seconds ago." << Log::end; return true; } @@ -288,6 +281,9 @@ bool DocumentBroker::sendUnoSave() auto queue = sessionIt.second->getQueue(); if (queue) { + // Invalidate the timestamp to force persisting. + _lastFileModifiedTime.fromEpochTime(0); + queue->put("uno .uno:Save"); // Set calc cell mode back to edit mode _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits