WebDAV: fixed backup/restore

contactServer() wasn't called before SyncSourceRevisions asked
for all items, which then failed with a boost::shared_ptr exception
on m_session.

Fixed this by wrapping the operations in
WebDAVSource::backup/restoreData which call contactServer() before
invoking the original implementation.

Function composition with boost::bind() might be nicer, but didn't
work right away (compile errors due to invalid syntax?) and thus
isn't used.
This commit is contained in:
Patrick Ohly 2011-06-20 10:48:00 +02:00
parent 6c8b5dbfdd
commit ea73be7454
2 changed files with 22 additions and 0 deletions

View file

@ -163,6 +163,12 @@ WebDAVSource::WebDAVSource(const SyncSourceParams &params,
m_contextSettings.reset(new ContextSettings(params.m_context));
m_settings = m_contextSettings;
}
/* insert contactServer() into BackupData_t and RestoreData_t (implemented by SyncSourceRevisions) */
m_operations.m_backupData = boost::bind(&WebDAVSource::backupData,
this, m_operations.m_backupData, _1, _2, _3);
m_operations.m_restoreData = boost::bind(&WebDAVSource::restoreData,
this, m_operations.m_restoreData, _1, _2, _3);
}
void WebDAVSource::replaceHTMLEntities(std::string &item)

View file

@ -190,6 +190,22 @@ class WebDAVSource : public TrackingSyncSource, private boost::noncopyable
RevisionMap_t &revisions,
bool &failed);
void backupData(const boost::function<Operations::BackupData_t> &op,
const Operations::ConstBackupInfo &oldBackup,
const Operations::BackupInfo &newBackup,
BackupReport &report) {
contactServer();
op(oldBackup, newBackup, report);
}
void restoreData(const boost::function<Operations::RestoreData_t> &op,
const Operations::ConstBackupInfo &oldBackup,
bool dryrun,
SyncSourceReport &report) {
contactServer();
op(oldBackup, dryrun, report);
}
/**
* Extracts ETag from response header, empty if not found.
*/