Commit c7f5318e authored by Jean-Francois Dockes's avatar Jean-Francois Dockes
Browse files

config checking: only test skippedPaths existence for user-added values, not defaults

parent 4989d1f9
......@@ -380,10 +380,10 @@ void RclConfig::setKeyDir(const string &dir)
m_defcharset.erase();
}
bool RclConfig::getConfParam(const string &name, int *ivp) const
bool RclConfig::getConfParam(const string &name, int *ivp, bool shallow) const
{
string value;
if (!getConfParam(name, value))
if (!getConfParam(name, value, shallow))
return false;
errno = 0;
long lval = strtol(value.c_str(), 0, 0);
......@@ -394,37 +394,39 @@ bool RclConfig::getConfParam(const string &name, int *ivp) const
return true;
}
bool RclConfig::getConfParam(const string &name, bool *bvp) const
bool RclConfig::getConfParam(const string &name, bool *bvp, bool shallow) const
{
if (!bvp)
return false;
*bvp = false;
string s;
if (!getConfParam(name, s))
if (!getConfParam(name, s, shallow))
return false;
*bvp = stringToBool(s);
return true;
}
bool RclConfig::getConfParam(const string &name, vector<string> *svvp) const
bool RclConfig::getConfParam(const string &name, vector<string> *svvp,
bool shallow) const
{
if (!svvp)
return false;
svvp->clear();
string s;
if (!getConfParam(name, s))
if (!getConfParam(name, s, shallow))
return false;
return stringToStrings(s, *svvp);
}
bool RclConfig::getConfParam(const string &name, vector<int> *vip) const
bool RclConfig::getConfParam(const string &name, vector<int> *vip,
bool shallow) const
{
if (!vip)
return false;
vip->clear();
vector<string> vs;
if (!getConfParam(name, &vs))
if (!getConfParam(name, &vs, shallow))
return false;
vip->reserve(vs.size());
for (unsigned int i = 0; i < vs.size(); i++) {
......
......@@ -123,21 +123,25 @@ class RclConfig {
string getKeyDir() const {return m_keydir;}
/** Get generic configuration parameter according to current keydir */
bool getConfParam(const string &name, string &value) const
bool getConfParam(const string &name, string &value,
bool shallow=false) const
{
if (m_conf == 0)
return false;
return m_conf->get(name, value, m_keydir);
return m_conf->get(name, value, m_keydir, shallow);
}
/** Variant with autoconversion to int */
bool getConfParam(const string &name, int *value) const;
bool getConfParam(const string &name, int *value, bool shallow=false) const;
/** Variant with autoconversion to bool */
bool getConfParam(const string &name, bool *value) const;
bool getConfParam(const string &name, bool *value,
bool shallow=false) const;
/** Variant with conversion to vector<string>
* (stringToStrings). Can fail if the string is malformed. */
bool getConfParam(const string &name, vector<string> *value) const;
bool getConfParam(const string &name, vector<string> *value,
bool shallow=false) const;
/** Variant with conversion to vector<int> */
bool getConfParam(const string &name, vector<int> *value) const;
bool getConfParam(const string &name, vector<int> *value,
bool shallow=false) const;
enum ThrStage {ThrIntern=0, ThrSplit=1, ThrDbWrite=2};
pair<int, int> getThrConf(ThrStage who) const;
......
......@@ -284,7 +284,9 @@ static bool checktopdirs(RclConfig *config, vector<string>& nonexist)
}
}
if (config->getConfParam("skippedPaths", &tdl)) {
// Check skippedPaths too, but only the user part (shallow==true), not
// the default values (e.g. /media, which might not exist).
if (config->getConfParam("skippedPaths", &tdl, true)) {
for (vector<string>::iterator it = tdl.begin(); it != tdl.end(); it++) {
*it = path_tildexpand(*it);
if (access(it->c_str(), 0) < 0) {
......@@ -293,7 +295,7 @@ static bool checktopdirs(RclConfig *config, vector<string>& nonexist)
}
}
if (config->getConfParam("daemSkippedPaths", &tdl)) {
if (config->getConfParam("daemSkippedPaths", &tdl, true)) {
for (vector<string>::iterator it = tdl.begin(); it != tdl.end(); it++) {
*it = path_tildexpand(*it);
if (access(it->c_str(), 0) < 0) {
......
......@@ -399,15 +399,21 @@ public:
return false;
}
virtual int get(const string &name, string &value, const string &sk) const
virtual int get(const string &name, string &value, const string &sk,
bool shallow) const
{
typename vector<T*>::const_iterator it;
for (it = m_confs.begin();it != m_confs.end();it++) {
if ((*it)->get(name, value, sk))
return true;
if (shallow)
break;
}
return false;
}
virtual int get(const string &name, string &value, const string &sk) const {
return get(name, value, sk, false);
}
virtual bool hasNameAnywhere(const string& nm) const
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment