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@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:
parent
1dd88e68ea
commit
2efaa6e06b
1 changed files with 4 additions and 1 deletions
|
@ -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 + "].");
|
||||
|
|
Loading…
Reference in a new issue