[evolution-data-server] Remove unnecessary cache refreshes from the Google Contacts backend



commit 792e6311ecd533be86e3d84e5aa3fda485fd9d91
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sat Nov 20 23:22:58 2010 +0000

    Remove unnecessary cache refreshes from the Google Contacts backend
    
    We shouldn't refresh the cache immediately after authenticating for two
    reasons:
     â?¢ If it fails, its error gets conflated with any errors from the
       authentication process.
     â?¢ We only need to update the cache if a view connects to the backend (and
       the backend consequently goes "live").
    
    We shouldn't refresh the cache before getting a contact or set of contacts
    because this will only ever cause a cache refresh if the refresh timeout has
    been reached, which would have already caused a refresh in the timeout
    handler.

 .../backends/google/e-book-backend-google.c        |   40 +-------------------
 1 files changed, 1 insertions(+), 39 deletions(-)
---
diff --git a/addressbook/backends/google/e-book-backend-google.c b/addressbook/backends/google/e-book-backend-google.c
index f1ca26a..5632d65 100644
--- a/addressbook/backends/google/e-book-backend-google.c
+++ b/addressbook/backends/google/e-book-backend-google.c
@@ -1023,26 +1023,11 @@ e_book_backend_google_get_contact (EBookBackend *backend, EDataBook *book, guint
 {
 	EContact *contact;
 	gchar *vcard_str;
-	GError *our_error = NULL;
 
 	__debug__ (G_STRFUNC);
 
-	/* Refresh the cache */
-	cache_refresh_if_needed (backend, &our_error);
-
-	if (our_error) {
-		GError *error = NULL;
-		data_book_error_from_gdata_error (&error, our_error);
-		__debug__ ("Getting contact with uid %s failed: %s", uid, our_error->message);
-		g_error_free (our_error);
-
-		e_data_book_respond_get_contact (book, opid, error, NULL);
-		return;
-	}
-
 	/* Get the contact */
 	contact = cache_get_contact (backend, uid, NULL);
-
 	if (!contact) {
 		__debug__ ("Getting contact with uid %s failed: Contact not found in cache.", uid);
 
@@ -1061,24 +1046,10 @@ static void
 e_book_backend_google_get_contact_list (EBookBackend *backend, EDataBook *book, guint32 opid, const gchar *query)
 {
 	EBookBackendSExp *sexp;
-	GError *our_error = NULL;
 	GList *all_contacts, *filtered_contacts = NULL;
 
 	__debug__ (G_STRFUNC);
 
-	/* Refresh the cache */
-	cache_refresh_if_needed (backend, &our_error);
-
-	if (our_error) {
-		GError *error = NULL;
-		data_book_error_from_gdata_error (&error, our_error);
-		__debug__ ("Getting all contacts failed: %s", our_error->message);
-		g_error_free (our_error);
-
-		e_data_book_respond_get_contact_list (book, opid, error, NULL);
-		return;
-	}
-
 	/* Get all contacts */
 	sexp = e_book_backend_sexp_new (query);
 	all_contacts = cache_get_contacts (backend);
@@ -1228,16 +1199,7 @@ authenticate_user_cb (GDataService *service, GAsyncResult *result, AuthenticateU
 	__debug__ (G_STRFUNC);
 
 	/* Finish authenticating */
-	if (!gdata_service_authenticate_finish (service, result, &gdata_error))
-		goto finish;
-
-	/* Update the cache if necessary */
-	cache_refresh_if_needed (data->backend, &gdata_error);
-	if (gdata_error)
-		goto finish;
-
-finish:
-	if (gdata_error) {
+	if (!gdata_service_authenticate_finish (service, result, &gdata_error)) {
 		data_book_error_from_gdata_error (&book_error, gdata_error);
 		__debug__ ("Authentication failed: %s", gdata_error->message);
 		g_error_free (gdata_error);



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