Make sure we increment the sync-token on PUT / DELETE.

This commit is contained in:
Andrew McMillan 2012-04-11 00:39:07 +12:00
parent 03b24c4d2f
commit 11cb332603
2 changed files with 9 additions and 3 deletions

View File

@ -80,20 +80,22 @@ else {
$cache = getCacheInstance();
$myLock = $cache->acquireLock('collection-'.$dav_resource->parent_path());
$collection_id = $dav_resource->GetProperty('collection_id');
$params = array( ':dav_id' => $dav_resource->resource_id() );
if ( $qry->QDo("SELECT write_sync_change(collection_id, 404, caldav_data.dav_name) FROM caldav_data WHERE dav_id = :dav_id", $params )
if ( $qry->QDo('SELECT new_sync_token(0,'.$collection_id.')')
&& $qry->QDo("SELECT write_sync_change(collection_id, 404, caldav_data.dav_name) FROM caldav_data WHERE dav_id = :dav_id", $params )
&& $qry->QDo("DELETE FROM property WHERE dav_name = (SELECT dav_name FROM caldav_data WHERE dav_id = :dav_id)", $params )
&& $qry->QDo("DELETE FROM locks WHERE dav_name = (SELECT dav_name FROM caldav_data WHERE dav_id = :dav_id)", $params )
&& $qry->QDo("DELETE FROM caldav_data WHERE dav_id = :dav_id", $params ) ) {
if ( function_exists('log_caldav_action') ) {
log_caldav_action( 'DELETE', $dav_resource->GetProperty('uid'), $dav_resource->GetProperty('user_no'), $dav_resource->GetProperty('collection_id'), $request->path );
log_caldav_action( 'DELETE', $dav_resource->GetProperty('uid'), $dav_resource->GetProperty('user_no'), $collection_id, $request->path );
}
$qry->Commit();
@dbg_error_log( "DELETE", "DELETE: User: %d, ETag: %s, Path: %s", $session->user_no, $request->etag_if_match, $request->path);
if ( function_exists('post_commit_action') ) {
post_commit_action( 'DELETE', $dav_resource->GetProperty('uid'), $dav_resource->GetProperty('user_no'), $dav_resource->GetProperty('collection_id'), $request->path );
post_commit_action( 'DELETE', $dav_resource->GetProperty('uid'), $dav_resource->GetProperty('user_no'), $collection_id, $request->path );
}
$cache->delete( 'collection-'.$dav_resource->parent_path(), null );

View File

@ -803,6 +803,9 @@ UPDATE calendar_item SET user_no=:user_no, dav_etag=:etag, uid=:uid, dtstamp=:dt
EOSQL;
$last_olson = '';
if ( count($resources) > 0 )
$qry->QDo('SELECT new_sync_token(0,'.$collection_id.')');
foreach( $resources AS $uid => $resource ) {
/** Construct the VCALENDAR data */
@ -1269,6 +1272,7 @@ function write_resource( DAVResource $resource, $caldav_data, DAVResource $colle
}
$qry->QDo('SELECT new_sync_token(0,'.$collection_id.')');
$calitem_params[':tzid'] = $tzid;
$calitem_params[':uid'] = $first->GetPValue('UID');