sync statistics: count items deleted during refresh-from-server (Bugzilla #3314)
The Synthesis Engine doesn't count these items because Synthesis wants the engine to count only items deleted by the remote side. For our statistics this looks a bit unrealistic (items before sync + added - deleted does not add up to items after sync), so we now track items deleted locally and use that number instead of the Synthesis statistics for deleted items when we know that it is not complete. In the command line, we show detailed statistics. In the GUI, it shows up as part of the locally applied changes. The new testComplexRefreshFromServerSemantic test covers this particular aspect of the statistics.
This commit is contained in:
parent
19db86bea6
commit
56cf08e4bf
|
@ -89,7 +89,17 @@ void DBusSyncClient::displaySourceProgress(sysync::TProgressEventEnum type,
|
|||
EvolutionSyncSource &source,
|
||||
int32_t extra1, int32_t extra2, int32_t extra3)
|
||||
{
|
||||
m_progress (g_strdup (source.getName()), type, extra1, extra2, extra3, m_userdata);
|
||||
m_progress (g_strdup (source.getName()), type, extra1, extra2,
|
||||
// Synthesis engine doesn't count locally
|
||||
// deleted items during
|
||||
// refresh-from-server. That's a matter of
|
||||
// taste. In SyncEvolution we'd like these
|
||||
// items to show up, so add it here.
|
||||
(type == sysync::PEV_DSSTATS_L &&
|
||||
source.getFinalSyncMode() == SYNC_REFRESH_FROM_SERVER) ?
|
||||
source.getNumDeleted() :
|
||||
extra3,
|
||||
m_userdata);
|
||||
EvolutionSyncClient::displaySourceProgress(type, source, extra1, extra2, extra3);
|
||||
}
|
||||
|
||||
|
|
|
@ -926,6 +926,13 @@ void EvolutionSyncClient::displaySourceProgress(sysync::TProgressEventEnum type,
|
|||
source.setItemStat(EvolutionSyncSource::ITEM_LOCAL,
|
||||
EvolutionSyncSource::ITEM_REMOVED,
|
||||
EvolutionSyncSource::ITEM_TOTAL,
|
||||
// Synthesis engine doesn't count locally
|
||||
// deleted items during
|
||||
// refresh-from-server. That's a matter of
|
||||
// taste. In SyncEvolution we'd like these
|
||||
// items to show up, so add it here.
|
||||
source.getFinalSyncMode() == SYNC_REFRESH_FROM_SERVER ?
|
||||
source.getNumDeleted() :
|
||||
extra3);
|
||||
break;
|
||||
case sysync::PEV_DSSTATS_R:
|
||||
|
|
|
@ -505,7 +505,11 @@ SyncMLStatus EvolutionSyncSource::updateItem(SyncItem& item) throw()
|
|||
|
||||
SyncMLStatus EvolutionSyncSource::deleteItem(SyncItem& item) throw()
|
||||
{
|
||||
return processItem("delete", &EvolutionSyncSource::deleteItemThrow, item, false);
|
||||
SyncMLStatus status = processItem("delete", &EvolutionSyncSource::deleteItemThrow, item, false);
|
||||
if (status == STATUS_OK) {
|
||||
incrementNumDeleted();
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
SyncMLStatus EvolutionSyncSource::removeAllItems() throw()
|
||||
|
@ -518,6 +522,7 @@ SyncMLStatus EvolutionSyncSource::removeAllItems() throw()
|
|||
item.setKey(key.c_str());
|
||||
logItem(item, "delete all items");
|
||||
deleteItemThrow(item);
|
||||
incrementNumDeleted();
|
||||
m_isModified = true;
|
||||
}
|
||||
} catch (...) {
|
||||
|
|
|
@ -352,6 +352,7 @@ class EvolutionSyncSource : public EvolutionSyncSourceConfig, public LoggerBase,
|
|||
m_deletedItems( *this, "deleted", SyncItem::DELETED ),
|
||||
m_isModified( false ),
|
||||
m_modTimeStamp(0),
|
||||
m_numDeleted(0),
|
||||
m_hasFailed( false )
|
||||
{
|
||||
}
|
||||
|
@ -722,6 +723,10 @@ class EvolutionSyncSource : public EvolutionSyncSourceConfig, public LoggerBase,
|
|||
va_list args);
|
||||
/**@}*/
|
||||
|
||||
long getNumDeleted() { return m_numDeleted; }
|
||||
void setNumDeleted(long num) { m_numDeleted = num; }
|
||||
void incrementNumDeleted() { m_numDeleted++; }
|
||||
|
||||
protected:
|
||||
#ifdef HAVE_EDS
|
||||
/**
|
||||
|
@ -856,6 +861,15 @@ class EvolutionSyncSource : public EvolutionSyncSourceConfig, public LoggerBase,
|
|||
/** time stamp of latest database modification, for sleepSinceModification() */
|
||||
time_t m_modTimeStamp;
|
||||
|
||||
/**
|
||||
* Counter for items deleted in the source. Has to be incremented
|
||||
* by RemoveAllItems() and DeleteItem(). This counter is used to
|
||||
* update the Synthesis engine counter in those cases where the
|
||||
* engine does not (refresh from server) or cannot
|
||||
* (RemoveAllItems()) count the removals itself.
|
||||
*/
|
||||
long m_numDeleted;
|
||||
|
||||
/** keeps track of failure state */
|
||||
bool m_hasFailed;
|
||||
|
||||
|
|
|
@ -1653,6 +1653,7 @@ void SyncTests::addTests() {
|
|||
ADD_TEST(SyncTests, testAddUpdate);
|
||||
ADD_TEST(SyncTests, testManyItems);
|
||||
ADD_TEST(SyncTests, testSlowSyncSemantic);
|
||||
ADD_TEST(SyncTests, testComplexRefreshFromServerSemantic);
|
||||
|
||||
if (config.updateItem) {
|
||||
ADD_TEST(SyncTests, testUpdate);
|
||||
|
@ -2674,6 +2675,34 @@ void SyncTests::testSlowSyncSemantic()
|
|||
CheckSyncReport(0,0,1, 0,0,0, true, SYNC_TWO_WAY)));
|
||||
}
|
||||
|
||||
/**
|
||||
* check that refresh-from-server works correctly:
|
||||
* - create the same item on A, server, B via testCopy()
|
||||
* - refresh B (one item deleted, one created)
|
||||
* - delete item on A and server
|
||||
* - refresh B (one item deleted)
|
||||
*/
|
||||
void SyncTests::testComplexRefreshFromServerSemantic()
|
||||
{
|
||||
testCopy();
|
||||
|
||||
// check refresh with one item on server
|
||||
accessClientB->doSync("refresh-one",
|
||||
SyncOptions(SYNC_REFRESH_FROM_SERVER,
|
||||
CheckSyncReport(1,0,1, 0,0,0, true, SYNC_REFRESH_FROM_SERVER)));
|
||||
|
||||
// delete that item via A, check again
|
||||
BOOST_FOREACH(source_array_t::value_type &source_pair, sources) {
|
||||
source_pair.second->deleteAll(source_pair.second->createSourceA);
|
||||
}
|
||||
doSync("delete-item",
|
||||
SyncOptions(SYNC_TWO_WAY,
|
||||
CheckSyncReport(0,0,0, 0,0,1, true, SYNC_TWO_WAY)));
|
||||
accessClientB->doSync("refresh-none",
|
||||
SyncOptions(SYNC_REFRESH_FROM_SERVER,
|
||||
CheckSyncReport(0,0,1, 0,0,0, true, SYNC_REFRESH_FROM_SERVER)));
|
||||
}
|
||||
|
||||
/**
|
||||
* implements testMaxMsg(), testLargeObject(), testLargeObjectEncoded()
|
||||
* using a sequence of items with varying sizes
|
||||
|
|
|
@ -908,6 +908,7 @@ protected:
|
|||
|
||||
virtual void testManyItems();
|
||||
virtual void testSlowSyncSemantic();
|
||||
virtual void testComplexRefreshFromServerSemantic();
|
||||
|
||||
virtual void doInterruptResume(int changes,
|
||||
boost::shared_ptr<TransportWrapper> wrapper);
|
||||
|
|
Loading…
Reference in New Issue