Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
added option resource-backend.purgeRemoved: known resources removed f…
Browse files Browse the repository at this point in the history
…rom resource backend are purged from store if true
  • Loading branch information
vaclavblazek committed Aug 30, 2021
1 parent 84bc765 commit 8b4199c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mapproxy/src/mapproxy/generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ class Generator : boost::noncopyable {
template <typename ProviderType>
ProviderType* getProvider() const;

/** Purges resource from disk. Be careful!
*/
void purge();

protected:
Generator(const Params &params, const Properties &props = Properties());

Expand Down Expand Up @@ -330,9 +334,10 @@ class Generator : boost::noncopyable {
class Generators : public boost::noncopyable {
public:
struct Config : Generator::Config {
int resourceUpdatePeriod;
int resourceUpdatePeriod = 100;
bool purgeRemovedResources = false;

Config() : resourceUpdatePeriod(100) {}
Config() {}
};

/** Creates generator set.
Expand Down
7 changes: 7 additions & 0 deletions mapproxy/src/mapproxy/generator/generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,10 @@ void Generator::updateRevision(unsigned int revision)
{
resource_.revision = std::max(resource_.revision, revision);
}

void Generator::purge()
{
boost::system::error_code ec;
fs::remove_all(root(), ec);
}

3 changes: 3 additions & 0 deletions mapproxy/src/mapproxy/generator/generators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ void Generators::Detail::update(const Resource::map &resources)
for (const auto &generator : toRemove) {
{
std::unique_lock<std::mutex> lock(lock_);
if (config_.purgeRemovedResources) {
generator->purge();
}
serving_.erase(generator);
}
}
Expand Down
6 changes: 6 additions & 0 deletions mapproxy/src/mapproxy/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ void Daemon::configuration(po::options_description &cmdline
"of resource types (available types: "
, enumerationString(Resource::Generator::Type{})
, ").").c_str())
("resource-backend.purgeRemoved"
, po::value(&generatorsConfig_.purgeRemovedResources)
->default_value(generatorsConfig_.purgeRemovedResources)->required()
, "Removed resources are purged from store if true. Use with care.")

("vts.builtinBrowserUrl"
, po::value(&variables_["VTS_BUILTIN_BROWSER_URL"])
Expand Down Expand Up @@ -324,6 +328,8 @@ void Daemon::configure(const po::variables_map &vars)
<< "\n\tresource-backend.freeze = ["
<< utility::join(generatorsConfig_.freezeResourceTypes, ",")
<< "]\n"
<< "\n\tresource-backend.purgeRemoved = "
<< generatorsConfig_.purgeRemovedResources << '\n'
<< "\thttp.externalUrl = " << generatorsConfig_.externalUrl << '\n'
<< utility::LManip([&](std::ostream &os) {
ResourceBackend::printConfig(os, "\t" + RBPrefixDotted
Expand Down

0 comments on commit 8b4199c

Please sign in to comment.