config templates: silently ignore missing template directory

Previously the getTemplate() method would throw an exception when
the directory cannot be read.
This commit is contained in:
Patrick Ohly 2009-04-17 14:09:17 +02:00
parent b0b0c977a9
commit d64b07c855

View file

@ -149,10 +149,15 @@ boost::shared_ptr<EvolutionSyncConfig> EvolutionSyncConfig::createServerTemplate
{
// case insensitive search for read-only file template config
string templateConfig(TEMPLATE_DIR);
ReadDir dir(templateConfig);
templateConfig = dir.find(boost::iequals(server, "default") ?
string("ScheduleWorld") : server,
false);
if (isDir(templateConfig)) {
ReadDir dir(templateConfig);
templateConfig = dir.find(boost::iequals(server, "default") ?
string("ScheduleWorld") : server,
false);
} else {
templateConfig = "";
}
if (templateConfig.empty()) {
// not found, avoid reading current directory by using one which doesn't exist
templateConfig = "/dev/null";