summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2017-04-12 12:32:59 +0200
committerJan Holesovsky <kendy@collabora.com>2017-04-12 20:08:54 +0200
commitacfbdfa3d59d3d52feae0f711f9d4af3fd71cd66 (patch)
tree8f64a42359371f509213f73b19d33f0a37513128
parent00af954041c72f00e2813f4102fe22b6f52fa946 (diff)
wsd - implemented an option to clean cache on doc close2.1-rc1
Includes also the following commit: Clean the cache even when the document was not modified. And rename the option, to match better the existing tile cache setting. Change-Id: I0bdb373efb93546527a168df2ed1c75539e95fe4
-rw-r--r--loolwsd.xml.in2
-rw-r--r--wsd/DocumentBroker.cpp4
-rw-r--r--wsd/LOOLWSD.cpp4
-rw-r--r--wsd/LOOLWSD.hpp1
-rw-r--r--wsd/TileCache.cpp9
-rw-r--r--wsd/TileCache.hpp3
6 files changed, 21 insertions, 2 deletions
diff --git a/loolwsd.xml.in b/loolwsd.xml.in
index 511b54792..5640d08f0 100644
--- a/loolwsd.xml.in
+++ b/loolwsd.xml.in
@@ -77,6 +77,8 @@
</webdav>
</storage>
+ <tile_cache_persistent desc="Should the tiles persist between two editing sessions of the given document?" type="bool" default="true">true</tile_cache_persistent>
+
<admin_console desc="Web admin console settings.">
<username desc="The username of the admin console. Must be set."></username>
<password desc="The password of the admin console. Must be set."></password>
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index e041db707..3cac2e706 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1198,6 +1198,10 @@ void DocumentBroker::destroyIfLastEditor(const std::string& id)
_markToDestroy = (_sessions.size() <= 1);
LOG_DBG("startDestroy on session [" << id << "] on docKey [" << _docKey <<
"], markToDestroy: " << _markToDestroy << ", lastEditableSession: " << _lastEditableSession);
+
+ // Remove all tiles related to this document from the cache.
+ if (_markToDestroy && !LOOLWSD::TileCachePersistent)
+ _tileCache->completeCleanup();
}
void DocumentBroker::setModified(const bool value)
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 57c635238..9d3c62fe3 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -553,6 +553,7 @@ static std::string UnitTestLibrary;
unsigned int LOOLWSD::NumPreSpawnedChildren = 0;
std::atomic<unsigned> LOOLWSD::NumConnections;
+bool LOOLWSD::TileCachePersistent = true;
std::unique_ptr<TraceFileWriter> LOOLWSD::TraceDumper;
/// This thread polls basic web serving, and handling of
@@ -610,6 +611,7 @@ void LOOLWSD::initialize(Application& self)
// Add default values of new entries here.
static const std::map<std::string, std::string> DefAppConfig
= { { "tile_cache_path", LOOLWSD_CACHEDIR },
+ { "tile_cache_persistent", "true" },
{ "sys_template_path", "systemplate" },
{ "lo_template_path", LO_PATH },
{ "child_root_path", "jails" },
@@ -762,6 +764,8 @@ void LOOLWSD::initialize(Application& self)
LOOLWSD::NumConnections = 0;
+ TileCachePersistent = getConfigValue<bool>(conf, "tile_cache_persistent", true);
+
// Command Tracing.
if (getConfigValue<bool>(conf, "trace[@enable]", false))
{
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 072a4a882..72c3a9a1a 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -53,6 +53,7 @@ public:
static std::string FileServerRoot;
static std::string LOKitVersion;
static std::atomic<unsigned> NumConnections;
+ static bool TileCachePersistent;
static std::unique_ptr<TraceFileWriter> TraceDumper;
/// Flag to shutdown the server.
diff --git a/wsd/TileCache.cpp b/wsd/TileCache.cpp
index b744eded5..ff30710f2 100644
--- a/wsd/TileCache.cpp
+++ b/wsd/TileCache.cpp
@@ -63,8 +63,7 @@ TileCache::TileCache(const std::string& docURL,
getTextFile("unsaved.txt", unsaved)))
{
// Document changed externally or modifications were not saved after all. Cache not useful.
- FileUtil::removeFile(_cacheDir, true);
- LOG_INF("Completely cleared tile cache: " << _cacheDir);
+ completeCleanup();
}
File(_cacheDir).createDirectories();
@@ -77,6 +76,12 @@ TileCache::~TileCache()
LOG_INF("~TileCache dtor for uri [" << _docURL << "].");
}
+void TileCache::completeCleanup() const
+{
+ FileUtil::removeFile(_cacheDir, true);
+ LOG_INF("Completely cleared tile cache: " << _cacheDir);
+}
+
/// Tracks the rendering of a given tile
/// to avoid duplication and help clock
/// rendering latency.
diff --git a/wsd/TileCache.hpp b/wsd/TileCache.hpp
index 96b5a5b3f..9f86cc72b 100644
--- a/wsd/TileCache.hpp
+++ b/wsd/TileCache.hpp
@@ -36,6 +36,9 @@ public:
TileCache(const std::string& docURL, const Poco::Timestamp& modifiedTime, const std::string& cacheDir);
~TileCache();
+ /// Remove the entire cache directory.
+ void completeCleanup() const;
+
TileCache(const TileCache&) = delete;
/// Subscribes if no subscription exists and returns the version number.