diff --git a/coolwsd.xml.in b/coolwsd.xml.in index 91fd87c688..25ef7d0fb1 100644 --- a/coolwsd.xml.in +++ b/coolwsd.xml.in @@ -64,6 +64,7 @@ 100 500 5000 + false 10000 60 diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index 25e6b1a74f..cd43b63178 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -551,15 +551,13 @@ bool ChildSession::_handleInput(const char *buffer, int length) } else if (tokens.equals(0, "save")) { - static bool doBgSave = !!getenv("COOL_BGSAVE"); + bool background = tokens[1] == "background=true"; + SigUtil::addActivity(getId(), (background ? "bg " : "") + firstLine); - SigUtil::addActivity(getId(), (doBgSave ? "bg " : "") + firstLine); - - bool autosave = tokens[1] == "autosave=true"; StringVector unoSave = StringVector::tokenize("uno .uno:Save " + tokens.cat(' ', 2)); bool saving = false; - if (doBgSave && autosave) + if (background) saving = !saveDocumentBackground(unoSave); if (!saving) diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 2c9ae82413..416c48d13b 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -184,6 +184,7 @@ DocumentBroker::DocumentBroker(ChildType type, const std::string& uri, const Poc , _wopiDownloadDuration(0) , _mobileAppDocId(mobileAppDocId) , _alwaysSaveOnExit(COOLWSD::getConfigValue("per_document.always_save_on_exit", false)) + , _backgroundAutoSave(COOLWSD::getConfigValue("per_document.background_autosave", true)) #if !MOBILEAPP , _admin(Admin::instance()) #endif @@ -2649,8 +2650,8 @@ void DocumentBroker::autoSaveAndStop(const std::string& reason) } bool DocumentBroker::sendUnoSave(const std::shared_ptr& session, - bool dontTerminateEdit, bool dontSaveIfUnmodified, bool isAutosave, - const std::string& extendedData) + bool dontTerminateEdit, bool dontSaveIfUnmodified, + bool isAutosave, const std::string& extendedData) { ASSERT_CORRECT_THREAD(); @@ -2689,8 +2690,12 @@ bool DocumentBroker::sendUnoSave(const std::shared_ptr& session, // If Core does report something different after saving, we'll update this flag. _nextStorageAttrs.setUserModified(isModified() || haveModifyActivityAfterSaveRequest()); + static bool forceBackgroundSave = !!getenv("COOL_FORCE_BGSAVE"); + // Note: It's odd to capture these here, but this function is used from ClientSession too. bool autosave = isAutosave || (_unitWsd && _unitWsd->isAutosave()); + bool background = forceBackgroundSave || (autosave && _backgroundAutoSave); + _nextStorageAttrs.setIsAutosave(autosave); _nextStorageAttrs.setExtendedData(extendedData); @@ -2698,7 +2703,7 @@ bool DocumentBroker::sendUnoSave(const std::shared_ptr& session, LOG_TRC("save arguments: " << saveArgs); // re-written to .uno:Save in the Kit. - const auto command = std::string("save autosave=") + (autosave ? "true" : "")+ " " + saveArgs; + const auto command = std::string("save background=") + (background ? "true" : "")+ " " + saveArgs; if (forwardToChild(session, command)) { _saveManager.markLastSaveRequestTime(); diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp index ca3f1fc168..f1c77832d1 100644 --- a/wsd/DocumentBroker.hpp +++ b/wsd/DocumentBroker.hpp @@ -1618,7 +1618,10 @@ private: std::map _embeddedMedia; /// True iff the config per_document.always_save_on_exit is true. - const bool _alwaysSaveOnExit; + const bool _alwaysSaveOnExit : 1; + + /// True iff the config per_document.background_autosave is true. + const bool _backgroundAutoSave : 1; #if !MOBILEAPP Admin& _admin;