mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-08-24 17:36:39 +00:00
[sync-remote] More attempts to handle Google.
It seems that on PUT Google might truncate the filename, so it will send us back a Location header we need to follow before we can getr the ETag. And there might be one more hoop to jump through to complete this process. This would be better handled if we locally use the VEVENT UID as the invariant property between local and remote, rather than the 'filename' part of the path, but we'd still face the issue of having to follow the Location: header to get the ETag for the event we just PUT to the remote server.
This commit is contained in:
parent
fa24f6a26e
commit
c5c97ad5d2
@ -382,9 +382,9 @@ if ( $sync_out ) {
|
||||
$new_etag = $caldav->DoPUTRequest( $args->url . $href, $push_events[$href], $etag );
|
||||
printf( "\nPUT:\n%s\nResponse:\n%s\n", $caldav->GetHttpRequest(), $caldav->GetResponseHeaders() );
|
||||
if ( !isset($new_etag) || $new_etag == '' ) {
|
||||
if ( preg_match( '{^Location:\s+.*/([^/]+)$}i', $caldav->GetResponseHeaders(), $matches ) ) {
|
||||
if ( preg_match( '{^Location:\s+.*/([^/]+)$}im', $caldav->GetResponseHeaders(), $matches ) ) {
|
||||
/** How annoying. It seems the other server renamed the event on PUT so we move the local copy to match their name */
|
||||
$new_href = $matches[1];
|
||||
$new_href = preg_replace( '{\r?\n.*$}s', '', $matches[1]);
|
||||
$qry = new AwlQuery('UPDATE caldav_data SET dav_name = :new_dav_name WHERE dav_name = :old_dav_name',
|
||||
array( ':new_dav_name' => $args->local_collection_path . $new_href,
|
||||
':old_dav_name' => $args->local_collection_path . $href ) );
|
||||
@ -394,6 +394,7 @@ if ( $sync_out ) {
|
||||
$href = $new_href;
|
||||
$caldav->DoHEADRequest( $args->url . $href );
|
||||
if ( preg_match( '{^Etag:\s+"([^"]*)"\s*$}im', $caldav->httpResponseHeaders, $matches ) ) $new_etag = $matches[1];
|
||||
printf( "\nHEAD:\n%s\nResponse:\n%s\n", $caldav->GetHttpRequest(), $caldav->GetResponseHeaders() );
|
||||
}
|
||||
if ( !isset($new_etag) || $new_etag == '' ) {
|
||||
printf( "Unable to retrieve ETag for new event on remote server. Forcing bad ctag.");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user