[evolution-data-server] WebDAV backends: Transform Precondition Failed error to E_CLIENT_ERROR_OUT_OF_SYNC



commit c8883474e6685a1e1ffacd2125e8cc3625e08a9e
Author: Milan Crha <mcrha redhat com>
Date:   Thu May 28 15:04:37 2020 +0200

    WebDAV backends: Transform Precondition Failed error to E_CLIENT_ERROR_OUT_OF_SYNC
    
    It's the evolution-data-server's error code used for these cases.

 src/addressbook/backends/carddav/e-book-backend-carddav.c       | 8 ++++++++
 src/calendar/backends/caldav/e-cal-backend-caldav.c             | 9 +++++++++
 src/calendar/backends/webdav-notes/e-cal-backend-webdav-notes.c | 9 +++++++++
 3 files changed, 26 insertions(+)
---
diff --git a/src/addressbook/backends/carddav/e-book-backend-carddav.c 
b/src/addressbook/backends/carddav/e-book-backend-carddav.c
index eff4d0bde..d3a33097f 100644
--- a/src/addressbook/backends/carddav/e-book-backend-carddav.c
+++ b/src/addressbook/backends/carddav/e-book-backend-carddav.c
@@ -1219,6 +1219,11 @@ ebb_carddav_save_contact_sync (EBookMetaBackend *meta_backend,
        g_free (etag);
        g_free (uid);
 
+       if (overwrite_existing && g_error_matches (local_error, SOUP_HTTP_ERROR, 
SOUP_STATUS_PRECONDITION_FAILED)) {
+               g_clear_error (&local_error);
+               local_error = EC_ERROR (E_CLIENT_ERROR_OUT_OF_SYNC);
+       }
+
        if (local_error) {
                ebb_carddav_check_credentials_error (bbdav, webdav, local_error);
                g_propagate_error (error, local_error);
@@ -1303,6 +1308,9 @@ ebb_carddav_remove_contact_sync (EBookMetaBackend *meta_backend,
        if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_NOT_FOUND)) {
                g_clear_error (&local_error);
                success = TRUE;
+       } else if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_PRECONDITION_FAILED)) {
+               g_clear_error (&local_error);
+               local_error = EC_ERROR (E_CLIENT_ERROR_OUT_OF_SYNC);
        }
 
        if (local_error) {
diff --git a/src/calendar/backends/caldav/e-cal-backend-caldav.c 
b/src/calendar/backends/caldav/e-cal-backend-caldav.c
index 5da655c82..f316426d6 100644
--- a/src/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/src/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -30,6 +30,7 @@
 
 #define E_CALDAV_X_ETAG "X-EVOLUTION-CALDAV-ETAG"
 
+#define EC_ERROR(_code) e_client_error_create (_code, NULL)
 #define ECC_ERROR(_code) e_cal_client_error_create (_code, NULL)
 #define ECC_ERROR_EX(_code, _msg) e_cal_client_error_create (_code, _msg)
 
@@ -1514,6 +1515,11 @@ ecb_caldav_save_component_sync (ECalMetaBackend *meta_backend,
        g_free (etag);
        g_free (uid);
 
+       if (overwrite_existing && g_error_matches (local_error, SOUP_HTTP_ERROR, 
SOUP_STATUS_PRECONDITION_FAILED)) {
+               g_clear_error (&local_error);
+               local_error = EC_ERROR (E_CLIENT_ERROR_OUT_OF_SYNC);
+       }
+
        if (local_error) {
                ecb_caldav_check_credentials_error (cbdav, webdav, local_error);
                g_propagate_error (error, local_error);
@@ -1598,6 +1604,9 @@ ecb_caldav_remove_component_sync (ECalMetaBackend *meta_backend,
        if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_NOT_FOUND)) {
                g_clear_error (&local_error);
                success = TRUE;
+       } else if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_PRECONDITION_FAILED)) {
+               g_clear_error (&local_error);
+               local_error = EC_ERROR (E_CLIENT_ERROR_OUT_OF_SYNC);
        }
 
        if (local_error) {
diff --git a/src/calendar/backends/webdav-notes/e-cal-backend-webdav-notes.c 
b/src/calendar/backends/webdav-notes/e-cal-backend-webdav-notes.c
index 63979ce44..dd9e05eaa 100644
--- a/src/calendar/backends/webdav-notes/e-cal-backend-webdav-notes.c
+++ b/src/calendar/backends/webdav-notes/e-cal-backend-webdav-notes.c
@@ -25,6 +25,7 @@
 
 #define E_WEBDAV_NOTES_X_ETAG "X-EVOLUTION-WEBDAV-NOTES-ETAG"
 
+#define EC_ERROR(_code) e_client_error_create (_code, NULL)
 #define ECC_ERROR(_code) e_cal_client_error_create (_code, NULL)
 #define ECC_ERROR_EX(_code, _msg) e_cal_client_error_create (_code, _msg)
 
@@ -1176,6 +1177,11 @@ ecb_webdav_notes_save_component_sync (ECalMetaBackend *meta_backend,
        g_free (href);
        g_free (etag);
 
+       if (overwrite_existing && g_error_matches (local_error, SOUP_HTTP_ERROR, 
SOUP_STATUS_PRECONDITION_FAILED)) {
+               g_clear_error (&local_error);
+               local_error = EC_ERROR (E_CLIENT_ERROR_OUT_OF_SYNC);
+       }
+
        if (local_error) {
                ecb_webdav_notes_check_credentials_error (cbnotes, webdav, local_error);
                g_propagate_error (error, local_error);
@@ -1236,6 +1242,9 @@ ecb_webdav_notes_remove_component_sync (ECalMetaBackend *meta_backend,
        if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_NOT_FOUND)) {
                g_clear_error (&local_error);
                success = TRUE;
+       } else if (g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_PRECONDITION_FAILED)) {
+               g_clear_error (&local_error);
+               local_error = EC_ERROR (E_CLIENT_ERROR_OUT_OF_SYNC);
        }
 
        if (local_error) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]