quarantine: keep quarantine off by default
allow path specification for the quarantine directory Signed-off-by: Pranam Lashkari <lpranam@collabora.com> Change-Id: I407288db60fe5fbf0f6a9346175c3d4acfd35addpull/3546/head
parent
686e6ccbc9
commit
e7c2f5cd07
|
@ -210,9 +210,10 @@
|
|||
<monitors desc="Addresses of servers we connect to on start for monitoring">
|
||||
</monitors>
|
||||
|
||||
<quarantine_files desc="Files are stored here to be examined later in cases of crashes or similar situation.">
|
||||
<quarantine_files desc="Files are stored here to be examined later in cases of crashes or similar situation." default="false" enable="false">
|
||||
<limit_dir_size_mb desc="Maximum directory size. On exceeding the specified limit, older files will be deleted." default="250" type="uint"></limit_dir_size_mb>
|
||||
<max_versions_to_maintain desc="How many versions of the same file to keep." default="2" type="uint"></max_versions_to_maintain>
|
||||
<path desc="Path to directory under which quarantined files will be stored" default="/opt/lool/quarantine"></path>
|
||||
</quarantine_files>
|
||||
|
||||
@FREEMIUM_CONFIGURATION@
|
||||
|
|
|
@ -1458,12 +1458,15 @@ void LOOLWSD::innerInitialize(Application& self)
|
|||
LOG_DBG("FileServerRoot after config: " << FileServerRoot);
|
||||
|
||||
//creating quarantine directory
|
||||
QuarantinePath = FileServerRoot + "quarantine/";
|
||||
Poco::File p(QuarantinePath);
|
||||
p.createDirectories();
|
||||
LOG_INF("Created quarantine directory " + p.path());
|
||||
if(getConfigValue<bool>(conf, "quarantine_files[@enable]", false))
|
||||
{
|
||||
QuarantinePath = getPathFromConfig("quarantine_files.path");
|
||||
Poco::File p(QuarantinePath);
|
||||
p.createDirectories();
|
||||
LOG_INF("Created quarantine directory " + p.path());
|
||||
|
||||
Quarantine::createQuarantineMap();
|
||||
Quarantine::createQuarantineMap();
|
||||
}
|
||||
|
||||
WelcomeFilesRoot = getPathFromConfig("welcome.path");
|
||||
if (!getConfigValue<bool>(conf, "welcome.enable", true))
|
||||
|
|
|
@ -21,6 +21,11 @@ namespace Quarantine
|
|||
{
|
||||
void createQuarantineMap()
|
||||
{
|
||||
bool enable = LOOLWSD::getConfigValue<bool>("quarantine_files[@enable]", false);
|
||||
|
||||
if (!enable)
|
||||
return;
|
||||
|
||||
std::vector<std::string> files;
|
||||
Poco::File(LOOLWSD::QuarantinePath).list(files);
|
||||
LOOLWSD::QuarantineMap.clear();
|
||||
|
@ -43,6 +48,11 @@ namespace Quarantine
|
|||
|
||||
void removeQuarantine()
|
||||
{
|
||||
bool enable = LOOLWSD::getConfigValue<bool>("quarantine_files[@enable]", false);
|
||||
|
||||
if (!enable)
|
||||
return;
|
||||
|
||||
FileUtil::removeFile(LOOLWSD::QuarantinePath, true);
|
||||
}
|
||||
|
||||
|
@ -51,6 +61,10 @@ namespace Quarantine
|
|||
// because they are originally stored in jails
|
||||
std::size_t quarantineSize()
|
||||
{
|
||||
bool enable = LOOLWSD::getConfigValue<bool>("quarantine_files[@enable]", false);
|
||||
|
||||
if (!enable)
|
||||
return 0;
|
||||
std::vector<std::string> files;
|
||||
Poco::File(LOOLWSD::QuarantinePath).list(files);
|
||||
std::size_t size = 0;
|
||||
|
@ -66,11 +80,13 @@ namespace Quarantine
|
|||
|
||||
void makeQuarantineSpace()
|
||||
{
|
||||
std::size_t sizeLimit = LOOLWSD::getConfigValue<std::size_t>("quarantine_files.limit_dir_size_mb", 0)*1024*1024;
|
||||
bool enable = LOOLWSD::getConfigValue<bool>("quarantine_files[@enable]", false);
|
||||
|
||||
if(sizeLimit == 0)
|
||||
if (!enable)
|
||||
return;
|
||||
|
||||
std::size_t sizeLimit = LOOLWSD::getConfigValue<std::size_t>("quarantine_files.limit_dir_size_mb", 0)*1024*1024;
|
||||
|
||||
std::vector<std::string> files;
|
||||
Poco::File(LOOLWSD::QuarantinePath).list(files);
|
||||
|
||||
|
@ -94,6 +110,11 @@ namespace Quarantine
|
|||
|
||||
void clearOldQuarantineVersions(std::string Wopiscr)
|
||||
{
|
||||
bool enable = LOOLWSD::getConfigValue<bool>("quarantine_files[@enable]", false);
|
||||
|
||||
if (!enable)
|
||||
return;
|
||||
|
||||
std::size_t maxVersionCount = LOOLWSD::getConfigValue<std::size_t>("quarantine_files.max_versions_to_maintain", 2);
|
||||
std::string decoded;
|
||||
Poco::URI::decode(Wopiscr, decoded);
|
||||
|
@ -107,10 +128,9 @@ namespace Quarantine
|
|||
|
||||
bool quarantineFile(DocumentBroker* docBroker, std::string docName)
|
||||
{
|
||||
//return if directory size limit is 0
|
||||
std::size_t sizeLimit = LOOLWSD::getConfigValue<std::size_t>("quarantine_files.limit_dir_size_mb", 0);
|
||||
bool enable = LOOLWSD::getConfigValue<bool>("quarantine_files[@enable]", false);
|
||||
|
||||
if (sizeLimit == 0)
|
||||
if (!enable)
|
||||
return false;
|
||||
|
||||
std::string docKey;
|
||||
|
|
Loading…
Reference in New Issue