2021-10-21 14:29:15 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
|
|
/*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
class DocumentBroker;
|
2023-05-08 06:57:30 -05:00
|
|
|
|
|
|
|
class Quarantine
|
2021-10-21 14:29:15 -05:00
|
|
|
{
|
2023-05-08 06:57:30 -05:00
|
|
|
public:
|
2023-05-08 07:11:01 -05:00
|
|
|
Quarantine(DocumentBroker& docBroker)
|
|
|
|
: _docBroker(docBroker)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-05-08 06:57:30 -05:00
|
|
|
static void initialize(const std::string& path);
|
2021-10-21 14:29:15 -05:00
|
|
|
|
2023-05-08 07:11:01 -05:00
|
|
|
bool quarantineFile(const std::string& docName);
|
2023-04-21 18:28:23 -05:00
|
|
|
|
|
|
|
/// Removes the quarantined files for the given DocKey when we unload gracefully.
|
2023-05-08 07:11:01 -05:00
|
|
|
void removeQuarantinedFiles();
|
2023-05-08 06:57:30 -05:00
|
|
|
|
|
|
|
private:
|
2023-05-08 07:11:01 -05:00
|
|
|
bool isQuarantineEnabled() const { return !QuarantinePath.empty(); }
|
2023-05-08 06:57:30 -05:00
|
|
|
|
2023-05-08 07:11:01 -05:00
|
|
|
std::size_t quarantineSize();
|
2023-05-08 06:57:30 -05:00
|
|
|
|
2023-05-08 07:11:01 -05:00
|
|
|
void makeQuarantineSpace();
|
2023-05-08 06:57:30 -05:00
|
|
|
|
2023-05-08 07:11:01 -05:00
|
|
|
void clearOldQuarantineVersions(const std::string& docKey);
|
2023-05-08 06:57:30 -05:00
|
|
|
|
2023-05-08 07:11:01 -05:00
|
|
|
void removeQuarantine();
|
2023-05-08 06:57:30 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
static std::string QuarantinePath;
|
2023-05-08 07:11:01 -05:00
|
|
|
|
|
|
|
DocumentBroker& _docBroker;
|
2023-05-08 06:57:30 -05:00
|
|
|
};
|