EDS contacts: avoid unnecessary DB writes during slow sync due to FILE-AS

EDS 3.8 sets X-EVOLUTION-FILE-AS to "last, first" when a contact is
created without it. This leads again to unnecessary DB updates because
the incoming item that the engine works with doesn't have that field
set.

To mitigate that issue, set FILE_AS (renamed to make the field name
valid in a script) like EDS would do during writing.

The downside is that all incoming items now have FILE_AS set, which
will overwrite a locally stored copy of that property even if the peer
did not store X-EVOLUTION-FILE-AS. Previously, as tested by
testExtension, the local value was preserved. There is no good solution
that works for both use cases, so allow X-EVOLUTION-FILE-AS to get lost
and relax the test.
This commit is contained in:
Patrick Ohly 2013-06-12 10:44:24 +02:00
parent d2a43b1e50
commit dfd0bc29af
4 changed files with 24 additions and 5 deletions

View file

@ -13,7 +13,7 @@
<field name="TITLE" type="string" compare="conflict" merge="fillempty"/>
<field name="FN" type="string" compare="conflict" merge="fillempty"/>
<field name="FILE-AS" type="string" compare="conflict" merge="fillempty"/>
<field name="FILE_AS" type="string" compare="conflict" merge="fillempty"/>
<field name="GENDER" type="string" compare="conflict" merge="fillempty"/>

View file

@ -29,9 +29,9 @@
<value field="FN"/>
</property>
<!-- FILE-AS not supported by KDE natively, let's use X-EVOLUTION-FILE-AS as extension -->
<!-- FILE_AS not supported by KDE natively, let's use X-EVOLUTION-FILE-AS as extension -->
<property name="X-EVOLUTION-FILE-AS">
<value field="FILE-AS"/>
<value field="FILE_AS"/>
</property>
<property name="X-GENDER">

View file

@ -99,6 +99,20 @@
}
}
}
// Ensure that FILE-AS is set. Some EDS versions will set it,
// so we need to do the same to ensure that incoming items
// match DB items during a slow sync.
if (FILE_AS == EMPTY) {
FILE_AS = N_LAST;
if (N_FIRST != EMPTY) {
if (FILE_AS != EMPTY) {
FILE_AS = FILE_AS + ", ";
}
FILE_AS = FILE_AS + N_FIRST;
}
}
$VCARD_OUTGOING_PHOTO_VALUE_SCRIPT;
]]></macro>

View file

@ -4340,8 +4340,13 @@ void SyncTests::testExtensions() {
// right source config and thus setting it must come after the
// createSourceB() call.
ScopedEnvChange env("CLIENT_TEST_SERVER", "");
ScopedEnvChange envParams("CLIENT_TEST_STRIP_PARAMETERS", "X-EVOLUTION-UI-SLOT");
ScopedEnvChange envProps("CLIENT_TEST_STRIP_PROPERTIES", "(PHOTO|FN)");
ScopedEnvChange envParams("CLIENT_TEST_STRIP_PARAMETERS", "X-EVOLUTION-UI-SLOT");
// X-EVOLUTION-FILE-AS is not preserved correctly with EDS due
// to setting it on incoming items. It is not always set as already stored
// locally, so when writing back, the new, artificially generated value overwrites
// the one chosen by the user. Not ideal, but the alternative (not setting it on
// incoming items) is worse.
ScopedEnvChange envProps("CLIENT_TEST_STRIP_PROPERTIES", "(PHOTO|FN|X-EVOLUTION-FILE-AS)");
if (!it->second->compareDatabases(refDir.c_str(), *source, false)) {
equal = false;
}