shared config + templates: must share global properties
The command line did not read the global defaultPeer property unless it found an existing context. This is an unnecessary optimization, reading from an non-existant context yields no properties except perhaps for defaultPeer, so we can do that and get the correct result with and without a context. Jussi mentioned that he didn't get defaultPeer when reading a template. Added TestMultipleConfigs.testSharedTemplate to verify that, but it passes without issues.
This commit is contained in:
parent
f4e530e421
commit
4de3b440ce
|
@ -721,33 +721,31 @@ void Cmdline::getFilters(const string &context,
|
|||
ConfigProps &syncFilter,
|
||||
map<string, ConfigProps> &sourceFilters)
|
||||
{
|
||||
// Read from context. If it does not exist, we simply set no properties
|
||||
// as filter. Previously there was a check for existance, but that was
|
||||
// flawed because it ignored the global property "defaultPeer".
|
||||
boost::shared_ptr<SyncConfig> shared(new SyncConfig(string("@") + context));
|
||||
if (shared->exists()) {
|
||||
shared->getProperties()->readProperties(syncFilter);
|
||||
BOOST_FOREACH(StringPair entry, m_syncProps) {
|
||||
syncFilter[entry.first] = entry.second;
|
||||
}
|
||||
|
||||
BOOST_FOREACH(std::string source, shared->getSyncSources()) {
|
||||
SyncSourceNodes nodes = shared->getSyncSourceNodes(source, "");
|
||||
ConfigProps &props = sourceFilters[source];
|
||||
nodes.getProperties()->readProperties(props);
|
||||
|
||||
// Special case "type" property: the value in the context
|
||||
// is not preserved. Every new peer must ensure that
|
||||
// its own value is compatible (= same backend) with
|
||||
// the other peers.
|
||||
props.erase("type");
|
||||
|
||||
BOOST_FOREACH(StringPair entry, m_sourceProps) {
|
||||
props[entry.first] = entry.second;
|
||||
}
|
||||
}
|
||||
sourceFilters[""] = m_sourceProps;
|
||||
} else {
|
||||
syncFilter = m_syncProps;
|
||||
sourceFilters[""] = m_sourceProps;
|
||||
shared->getProperties()->readProperties(syncFilter);
|
||||
BOOST_FOREACH(StringPair entry, m_syncProps) {
|
||||
syncFilter[entry.first] = entry.second;
|
||||
}
|
||||
|
||||
BOOST_FOREACH(std::string source, shared->getSyncSources()) {
|
||||
SyncSourceNodes nodes = shared->getSyncSourceNodes(source, "");
|
||||
ConfigProps &props = sourceFilters[source];
|
||||
nodes.getProperties()->readProperties(props);
|
||||
|
||||
// Special case "type" property: the value in the context
|
||||
// is not preserved. Every new peer must ensure that
|
||||
// its own value is compatible (= same backend) with
|
||||
// the other peers.
|
||||
props.erase("type");
|
||||
|
||||
BOOST_FOREACH(StringPair entry, m_sourceProps) {
|
||||
props[entry.first] = entry.second;
|
||||
}
|
||||
}
|
||||
sourceFilters[""] = m_sourceProps;
|
||||
}
|
||||
|
||||
void Cmdline::listSources(SyncSource &syncSource, const string &header)
|
||||
|
|
|
@ -1385,6 +1385,15 @@ class TestMultipleConfigs(unittest.TestCase, DBusUtil):
|
|||
self.failIf("source/addressbook" in config)
|
||||
self.session.Detach()
|
||||
|
||||
def testSharedTemplate(self):
|
||||
"""templates must contain shared properties"""
|
||||
self.setupConfigs()
|
||||
|
||||
config = self.server.GetConfig("scheduleworld", True, utf8_strings=True)
|
||||
self.failUnlessEqual(config[""]["defaultPeer"], "foobar_peer")
|
||||
self.failUnlessEqual(config[""]["deviceId"], "shared-device-identifier")
|
||||
self.failUnlessEqual(config["source/addressbook"]["evolutionsource"], "Work")
|
||||
|
||||
def testOtherContext(self):
|
||||
"""write into independent context"""
|
||||
self.setupConfigs()
|
||||
|
|
Loading…
Reference in New Issue