diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2021-01-26 22:40:04 -0500 |
---|---|---|
committer | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2021-01-31 22:23:21 -0500 |
commit | 026d62db3dc2f25e53b7aa4fa99f76d97ea44f0b (patch) | |
tree | 20762b2d3952be06e7c5127b925346a3bf86ca0a | |
parent | wsd: move lastFileModifiedTime into SaveManager (diff) | |
download | online-private/ash/saveman.tar.gz online-private/ash/saveman.zip |
wsd: lastFileModifiedTime -> modifiedTime
private/ash/saveman
The SaveManager is responsible for the file on disk.
Change-Id: I92f7843375fdc875bc7d1af3fba387f67a4f0ca5
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
-rw-r--r-- | wsd/DocumentBroker.cpp | 30 | ||||
-rw-r--r-- | wsd/DocumentBroker.hpp | 12 |
2 files changed, 17 insertions, 25 deletions
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 850e44aeda..4339301943 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -770,14 +770,13 @@ bool DocumentBroker::download(const std::shared_ptr<ClientSession>& session, con { // Check if document has been modified by some external action LOG_TRC("Document modified time: " << fileInfo.getModifiedTime()); - static const std::chrono::system_clock::time_point Zero; - if (_documentLastModifiedTime != Zero && - fileInfo.getModifiedTime() != Zero && - _documentLastModifiedTime != fileInfo.getModifiedTime()) + constexpr std::chrono::system_clock::time_point Zero; + if (_documentLastModifiedTime != Zero && fileInfo.getModifiedTime() != Zero + && _documentLastModifiedTime != fileInfo.getModifiedTime()) { - LOG_DBG("Document " << _docKey << "] has been modified behind our back. " << - "Informing all clients. Expected: " << _documentLastModifiedTime << - ", Actual: " << fileInfo.getModifiedTime()); + LOG_DBG("Document " << _docKey << "] has been modified behind our back. " + << "Informing all clients. Expected: " << _documentLastModifiedTime + << ", Actual: " << fileInfo.getModifiedTime()); _documentChangedInStorage = true; const std::string message = isModified() ? "error: cmd=storage kind=documentconflict" @@ -894,7 +893,7 @@ bool DocumentBroker::download(const std::shared_ptr<ClientSession>& session, con _filename = fileInfo.getFilename(); // Use the local temp file's timestamp. - _saveManager.setLastFileModifiedTime( + _saveManager.setModifiedTime( templateSource.empty() ? FileUtil::Stat(_storage->getRootFilePath()).modifiedTimepoint() : std::chrono::system_clock::time_point()); @@ -905,8 +904,8 @@ bool DocumentBroker::download(const std::shared_ptr<ClientSession>& session, con dontUseCache = true; #endif - _tileCache = Util::make_unique<TileCache>( - _storage->getUriString(), _saveManager.getLastFileModifiedTime(), dontUseCache); + _tileCache = Util::make_unique<TileCache>(_storage->getUriString(), + _saveManager.getModifiedTime(), dontUseCache); _tileCache->setThreadOwner(std::this_thread::get_id()); } @@ -1060,12 +1059,11 @@ void DocumentBroker::uploadToStorageInternal(const std::string& sessionId, bool // If the file timestamp hasn't changed, skip saving. const std::chrono::system_clock::time_point newFileModifiedTime = FileUtil::Stat(_storage->getRootFilePath()).modifiedTimepoint(); - if (!isSaveAs && newFileModifiedTime == _saveManager.getLastFileModifiedTime() && !isRename - && !force) + if (!isSaveAs && newFileModifiedTime == _saveManager.getModifiedTime() && !isRename && !force) { // Nothing to do. const auto timeInSec = std::chrono::duration_cast<std::chrono::seconds>( - std::chrono::system_clock::now() - _saveManager.getLastFileModifiedTime()); + std::chrono::system_clock::now() - _saveManager.getModifiedTime()); LOG_DBG("Skipping unnecessary uploading to URI [" << uriAnonym << "] with docKey [" << _docKey << "]. File last modified " << timeInSec.count() << " seconds ago, timestamp unchanged."); _poll->wakeup(); @@ -1102,7 +1100,7 @@ void DocumentBroker::handleUploadToStorageResponse(const StorageUploadDetails& d if (!details.isSaveAs && !details.isRename) { // Saved and stored; update flags. - _saveManager.setLastFileModifiedTime(details.newFileModifiedTime); + _saveManager.setModifiedTime(details.newFileModifiedTime); _lastSaveTime = std::chrono::steady_clock::now(); // Save the storage timestamp. @@ -1390,7 +1388,7 @@ bool DocumentBroker::sendUnoSave(const std::string& sessionId, bool dontTerminat if (_sessions.find(sessionId) != _sessions.end()) { // Invalidate the timestamp to force persisting. - _saveManager.setLastFileModifiedTime(std::chrono::system_clock::time_point()); + _saveManager.setModifiedTime(std::chrono::system_clock::time_point()); // We do not want save to terminate editing mode if we are in edit mode now @@ -2604,7 +2602,7 @@ void DocumentBroker::dumpState(std::ostream& os) << Util::getSteadyClockAsString(_saveManager.lastSaveResponseTime()); os << "\n last storage save was successful: " << isLastStorageUploadSuccessful(); os << "\n last modified: " << Util::getHttpTime(_documentLastModifiedTime); - os << "\n file last modified: " << Util::getHttpTime(_saveManager.getLastFileModifiedTime()); + os << "\n file last modified: " << Util::getHttpTime(_saveManager.getModifiedTime()); if (_limitLifeSeconds > std::chrono::seconds::zero()) os << "\n life limit in seconds: " << _limitLifeSeconds.count(); os << "\n idle time: " << getIdleTimeSecs(); diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp index 95b25c52fc..e3f45b0487 100644 --- a/wsd/DocumentBroker.hpp +++ b/wsd/DocumentBroker.hpp @@ -610,15 +610,9 @@ private: >= std::chrono::milliseconds(COMMAND_TIMEOUT_MS); } - std::chrono::system_clock::time_point getLastFileModifiedTime() const - { - return _lastFileModifiedTime; - } + std::chrono::system_clock::time_point getModifiedTime() const { return _modifiedTime; } - void setLastFileModifiedTime(std::chrono::system_clock::time_point time) - { - _lastFileModifiedTime = time; - } + void setModifiedTime(std::chrono::system_clock::time_point time) { _modifiedTime = time; } private: /// Helper to get the current time. @@ -638,7 +632,7 @@ private: std::chrono::steady_clock::time_point _lastSaveResponseTime; /// The jailed file last-modified time. - std::chrono::system_clock::time_point _lastFileModifiedTime; + std::chrono::system_clock::time_point _modifiedTime; /// Whether auto-saving is enabled at all or not. const bool _isAutosaveEnabled; |