* Fixes NB#102317, do not update the last time updated if the inbox refresh fails
[modest] / src / modest-mail-operation.c
index 30f1a57..39d1629 100644 (file)
@@ -1329,8 +1329,7 @@ G_DEFINE_TYPE_WITH_CODE (InternalFolderObserver,
 static void
 foreach_add_item (gpointer header, gpointer user_data)
 {
-       tny_list_prepend (TNY_LIST (user_data), 
-                         G_OBJECT (header));
+       tny_list_append (TNY_LIST (user_data), G_OBJECT (header));
 }
 
 /* This is the method that looks for new messages in a folder */
@@ -1411,9 +1410,9 @@ update_account_send_mail (UpdateAccountInfo *info)
                return;
 
        /* Get the transport account */
-       transport_account = (TnyTransportAccount *)
-               modest_tny_account_store_get_transport_account_for_open_connection (account_store,
-                                                                                   info->account_name);
+       transport_account = (TnyTransportAccount *) 
+               modest_tny_account_store_get_server_account (account_store, info->account_name, 
+                                                            TNY_ACCOUNT_TYPE_TRANSPORT);
 
        if (transport_account) {
                ModestTnySendQueue *send_queue;
@@ -1536,7 +1535,7 @@ inbox_refreshed_cb (TnyFolder *inbox,
        UpdateAccountInfo *info;
        ModestMailOperationPrivate *priv;
        TnyIterator *new_headers_iter;
-       GPtrArray *new_headers_array = NULL;   
+       GPtrArray *new_headers_array = NULL;
        gint max_size, retrieve_limit, i;
        ModestAccountMgr *mgr;
        ModestAccountRetrieveType retrieve_type;
@@ -1547,9 +1546,6 @@ inbox_refreshed_cb (TnyFolder *inbox,
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE (info->mail_op);
        mgr = modest_runtime_get_account_mgr ();
 
-       /* Set the last updated as the current time, do it even if the inbox refresh failed */
-       modest_account_mgr_set_last_updated (mgr, tny_account_get_id (priv->account), time (NULL));
-
        if (canceled || err) {
                priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
                if (err)
@@ -1573,6 +1569,9 @@ inbox_refreshed_cb (TnyFolder *inbox,
                goto send_mail;
        }
 
+       /* Set the last updated as the current time */
+       modest_account_mgr_set_last_updated (mgr, tny_account_get_id (priv->account), time (NULL));
+
        /* Get the message max size */
        max_size  = modest_conf_get_int (modest_runtime_get_conf (),
                                         MODEST_CONF_MSG_SIZE_LIMIT, NULL);