check filesystem before trying to open plugin + only report unique directories searched - closes #2131
Conflicts: src/datasource_cache.cpp
This commit is contained in:
parent
f6b74ff819
commit
88613fc2ec
2 changed files with 12 additions and 6 deletions
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
namespace mapnik {
|
namespace mapnik {
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ private:
|
||||||
~datasource_cache();
|
~datasource_cache();
|
||||||
std::map<std::string,std::shared_ptr<PluginInfo> > plugins_;
|
std::map<std::string,std::shared_ptr<PluginInfo> > plugins_;
|
||||||
bool registered_;
|
bool registered_;
|
||||||
std::vector<std::string> plugin_directories_;
|
std::set<std::string> plugin_directories_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,8 +165,7 @@ void datasource_cache::register_datasources(std::string const& str)
|
||||||
#ifdef MAPNIK_THREADSAFE
|
#ifdef MAPNIK_THREADSAFE
|
||||||
mapnik::scoped_lock lock(mutex_);
|
mapnik::scoped_lock lock(mutex_);
|
||||||
#endif
|
#endif
|
||||||
// TODO - only push unique paths
|
plugin_directories_.insert(str);
|
||||||
plugin_directories_.push_back(str);
|
|
||||||
if (mapnik::util::exists(str) && mapnik::util::is_directory(str))
|
if (mapnik::util::exists(str) && mapnik::util::is_directory(str))
|
||||||
{
|
{
|
||||||
boost::filesystem::directory_iterator end_itr;
|
boost::filesystem::directory_iterator end_itr;
|
||||||
|
@ -194,9 +193,15 @@ void datasource_cache::register_datasources(std::string const& str)
|
||||||
|
|
||||||
bool datasource_cache::register_datasource(std::string const& filename)
|
bool datasource_cache::register_datasource(std::string const& filename)
|
||||||
{
|
{
|
||||||
bool success = false;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (!mapnik::util::exists(filename))
|
||||||
|
{
|
||||||
|
MAPNIK_LOG_ERROR(datasource_cache)
|
||||||
|
<< "Cannot load '"
|
||||||
|
<< filename << "' (plugin does not exist)";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
std::shared_ptr<PluginInfo> plugin = std::make_shared<PluginInfo>(filename,"datasource_name");
|
std::shared_ptr<PluginInfo> plugin = std::make_shared<PluginInfo>(filename,"datasource_name");
|
||||||
if (plugin->valid())
|
if (plugin->valid())
|
||||||
{
|
{
|
||||||
|
@ -212,7 +217,7 @@ bool datasource_cache::register_datasource(std::string const& filename)
|
||||||
MAPNIK_LOG_DEBUG(datasource_cache)
|
MAPNIK_LOG_DEBUG(datasource_cache)
|
||||||
<< "datasource_cache: Registered="
|
<< "datasource_cache: Registered="
|
||||||
<< plugin->name();
|
<< plugin->name();
|
||||||
success = true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -228,7 +233,7 @@ bool datasource_cache::register_datasource(std::string const& filename)
|
||||||
<< "Exception caught while loading plugin library: "
|
<< "Exception caught while loading plugin library: "
|
||||||
<< filename << " (" << ex.what() << ")";
|
<< filename << " (" << ex.what() << ")";
|
||||||
}
|
}
|
||||||
return success;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue