* Fixes NB#64270, now it's not possible to move a folder into itself
[modest] / src / modest-mail-operation.c
index 9780168..4d16d48 100644 (file)
@@ -417,8 +417,8 @@ modest_mail_operation_cancel (ModestMailOperation *self)
        /* Cancel the mail operation. We need to wrap it between this
           start/stop operations to allow following calls to the
           account */
-       if (priv->account)
-               tny_account_cancel (priv->account);
+       g_return_val_if_fail (priv->account, FALSE);
+       tny_account_cancel (priv->account);
 
        return canceled;
 }
@@ -1770,7 +1770,9 @@ modest_mail_operation_xfer_folder (ModestMailOperation *self,
                parent_rules = modest_tny_folder_get_rules (TNY_FOLDER (parent));
        
        /* The moveable restriction is applied also to copy operation */
-       if ((!TNY_IS_FOLDER_STORE (parent)) || (rules & MODEST_FOLDER_RULES_FOLDER_NON_MOVEABLE)) {
+       if ((gpointer) parent == (gpointer) folder ||
+           (!TNY_IS_FOLDER_STORE (parent)) || 
+           (rules & MODEST_FOLDER_RULES_FOLDER_NON_MOVEABLE)) {
                printf("DEBUG: %s: Not allowing the move.\n", __FUNCTION__);
                /* Set status failed and set an error */
                priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;