VirtualSyncSource, MapSyncSource: implement m_isEmpty

This is relevant for isUsable() and not so much (not at all?) for
slow sync prevention.
This commit is contained in:
Patrick Ohly 2014-08-20 16:23:15 +02:00
parent 8ac69096e8
commit dec741ea50
3 changed files with 25 additions and 0 deletions

View File

@ -56,6 +56,7 @@ MapSyncSource::MapSyncSource(const SyncSourceParams &params,
m_operations.m_backupData = m_sub->getOperations().m_backupData;
m_operations.m_restoreData = m_sub->getOperations().m_restoreData;
}
m_operations.m_isEmpty = m_sub->getOperations().m_isEmpty;
}
void MapSyncSource::enableServerMode()

View File

@ -536,6 +536,8 @@ VirtualSyncSource::VirtualSyncSource(const SyncSourceParams &params, SyncConfig
evoSyncSource.c_str()));
}
}
m_operations.m_isEmpty = boost::bind(&VirtualSyncSource::isEmpty, this);
}
void VirtualSyncSource::open()
@ -546,6 +548,27 @@ void VirtualSyncSource::open()
}
}
bool VirtualSyncSource::isEmpty()
{
bool empty = true;
SuspendFlags &s = SuspendFlags::getSuspendFlags();
BOOST_FOREACH(boost::shared_ptr<SyncSource> &source, m_sources) {
// Operation might not be implemented, in which case we have to
// assume "not empty".
if (!source->getOperations().m_isEmpty ||
!source->getOperations().m_isEmpty()) {
empty = false;
// Keep checking, because isEmpty() is also used for
// isUsable() and we have to touch all sources for that.
}
// Operation might have been aborted by user, need to check.
s.checkForNormal();
}
return empty;
}
void VirtualSyncSource::close()
{
BOOST_FOREACH(boost::shared_ptr<SyncSource> &source, m_sources) {

View File

@ -2230,6 +2230,7 @@ class DummySyncSource : public SyncSource
class VirtualSyncSource : public DummySyncSource
{
std::vector< boost::shared_ptr<SyncSource> > m_sources;
bool isEmpty();
public:
/**