[Libreoffice-commits] online.git: loolwsd.xml.in wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jun 6 09:49:17 UTC 2019
loolwsd.xml.in | 1 +
wsd/DocumentBroker.cpp | 8 +++++---
wsd/DocumentBroker.hpp | 3 ++-
3 files changed, 8 insertions(+), 4 deletions(-)
New commits:
commit 717816d44d854c40b3a95f44b7204f152bce9f15
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Jun 6 11:48:54 2019 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Jun 6 11:48:54 2019 +0200
wsd: add new always_save_on_exit config option
The default behavior is unchanged: once the last editor exits, we still
only perform a save when the document is modified.
It's possible to opt in for the new behavior, though: in that case the
save after the exit of the last editor will happen even for unmodified
documents.
Change-Id: I14c17035a932cf952217f3b71fdef57fede0ce24
diff --git a/loolwsd.xml.in b/loolwsd.xml.in
index b0fd22464..aa2e1f481 100644
--- a/loolwsd.xml.in
+++ b/loolwsd.xml.in
@@ -23,6 +23,7 @@
<!-- They are disabled when the value is zero or negative. -->
<idlesave_duration_secs desc="The number of idle seconds after which document, if modified, should be saved. Defaults to 30 seconds." type="int" default="30">30</idlesave_duration_secs>
<autosave_duration_secs desc="The number of seconds after which document, if modified, should be saved. Defaults to 5 minutes." type="int" default="300">300</autosave_duration_secs>
+ <always_save_on_exit desc="On exiting the last editor, always perform the save, even if the document is not modified." type="bool" default="false">false</always_save_on_exit>
<limit_virt_mem_kb desc="The maximum virtual memory allowed to each document process. 0 for unlimited, 1700 min." type="uint">0</limit_virt_mem_kb>
<limit_data_mem_kb desc="The maximum memory data segment allowed to each document process. 0 for unlimited." type="uint">0</limit_data_mem_kb>
<limit_stack_mem_kb desc="The maximum stack size allowed to each document process. 0 for unlimited." type="uint">8000</limit_stack_mem_kb>
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 34f520b31..8429aa96f 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -989,7 +989,7 @@ void DocumentBroker::setLoaded()
}
}
-bool DocumentBroker::autoSave(const bool force)
+bool DocumentBroker::autoSave(const bool force, const bool dontSaveIfUnmodified)
{
assertCorrectThread();
@@ -1033,7 +1033,7 @@ bool DocumentBroker::autoSave(const bool force)
// triggered when the document is closed. In the case of network disconnection or browser crash
// most users would want to have had the chance to hit save before the document unloaded.
sent = sendUnoSave(savingSessionId, /*dontTerminateEdit=*/true,
- /*dontSaveIfUnmodified=*/true, /*isAutosave=*/false,
+ dontSaveIfUnmodified, /*isAutosave=*/false,
/*isExitSave=*/true);
}
else if (_isModified)
@@ -1228,8 +1228,10 @@ size_t DocumentBroker::removeSession(const std::string& id)
"]. Have " << _sessions.size() << " sessions. markToDestroy: " << _markToDestroy <<
", LastEditableSession: " << lastEditableSession);
+ const auto dontSaveIfUnmodified = !LOOLWSD::getConfigValue<bool>("per_document.always_save_on_exit", false);
+
// If last editable, save and don't remove until after uploading to storage.
- if (!lastEditableSession || !autoSave(isPossiblyModified()))
+ if (!lastEditableSession || !autoSave(isPossiblyModified(), dontSaveIfUnmodified))
removeSessionInternal(id);
}
catch (const std::exception& ex)
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 1923d3b93..e6e20692b 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -254,9 +254,10 @@ public:
/// Save the document if the document is modified.
/// @param force when true, will force saving if there
/// has been any recent activity after the last save.
+ /// @param dontSaveIfUnmodified when true, save will fail if the document is not modified.
/// @return true if attempts to save or it also waits
/// and receives save notification. Otherwise, false.
- bool autoSave(const bool force);
+ bool autoSave(const bool force, const bool dontSaveIfUnmodified = true);
Poco::URI getPublicUri() const { return _uriPublic; }
const std::string& getJailId() const { return _jailId; }
More information about the Libreoffice-commits
mailing list