~ubuntu-branches/ubuntu/raring/dovecot/raring

« back to all changes in this revision

Viewing changes to src/lib-storage/mail-storage.c

  • Committer: Package Import Robot
  • Author(s): Marco Nenciarini
  • Date: 2011-09-19 19:26:48 UTC
  • mfrom: (1.14.4 upstream)
  • mto: (4.8.2 experimental)
  • mto: This revision was merged to the branch mainline in revision 86.
  • Revision ID: package-import@ubuntu.com-20110919192648-ri3sovtiz334yori
Tags: 1:2.0.15-1
* [a22575a] New upstream version 2.0.15: (Closes: #642045)
    + doveadm altmove: Added -r parameter to move mails back to primary
      storage.
    - v2.0.14: Index reading could have eaten a lot of memory in some
      situations
    - doveadm index no longer affects future caching decisions
    - mbox: Fixed crash during mail delivery when mailbox didn't yet have
      GUID assigned to it.
    - zlib+mbox: Fetching last message from compressed mailboxes crashed.
    - lib-sql: Fixed load balancing and error
* [8ce5abc] Update pigeonhole to release 0.2.4
* [87658d2] Add dovecot-solr to dovecot-core's Suggests line.

Show diffs side-by-side

added added

removed removed

Lines of Context:
805
805
 
806
806
static bool
807
807
mail_storages_rename_compatible(struct mail_storage *storage1,
808
 
                                struct mail_storage *storage2)
 
808
                                struct mail_storage *storage2,
 
809
                                const char **error_r)
809
810
{
810
811
        if (storage1 == storage2)
811
812
                return TRUE;
812
813
 
813
 
        if (strcmp(storage1->name, storage2->name) != 0)
814
 
                return FALSE;
815
 
        if ((storage1->class_flags & MAIL_STORAGE_CLASS_FLAG_UNIQUE_ROOT) != 0)
816
 
                return FALSE;
 
814
        if (strcmp(storage1->name, storage2->name) != 0) {
 
815
                *error_r = t_strdup_printf("storage %s != %s",
 
816
                                           storage1->name, storage2->name);
 
817
                return FALSE;
 
818
        }
 
819
        if ((storage1->class_flags & MAIL_STORAGE_CLASS_FLAG_UNIQUE_ROOT) != 0) {
 
820
                /* e.g. mdbox where all mails are in storage/ directory and
 
821
                   they can't be easily moved from there. */
 
822
                *error_r = t_strdup_printf("storage %s uses unique root",
 
823
                                           storage1->name);
 
824
                return FALSE;
 
825
        }
817
826
        return TRUE;
818
827
}
819
828
 
824
833
 
825
834
static bool
826
835
mailbox_lists_rename_compatible(struct mailbox_list *list1,
827
 
                                struct mailbox_list *list2)
 
836
                                struct mailbox_list *list2,
 
837
                                const char **error_r)
828
838
{
829
 
        return nullequals(list1->set.alt_dir, list2->set.alt_dir) &&
830
 
                nullequals(list1->set.index_dir, list2->set.index_dir) &&
831
 
                nullequals(list1->set.control_dir, list2->set.control_dir);
 
839
        if (!nullequals(list1->set.alt_dir, list2->set.alt_dir)) {
 
840
                *error_r = "one namespace has alt dir and another doesn't";
 
841
                return FALSE;
 
842
        }
 
843
        if (!nullequals(list1->set.index_dir, list2->set.index_dir)) {
 
844
                *error_r = "one namespace has index dir and another doesn't";
 
845
                return FALSE;
 
846
        }
 
847
        if (!nullequals(list1->set.control_dir, list2->set.control_dir)) {
 
848
                *error_r = "one namespace has control dir and another doesn't";
 
849
                return FALSE;
 
850
        }
 
851
        return TRUE;
832
852
}
833
853
 
834
854
int mailbox_rename(struct mailbox *src, struct mailbox *dest,
835
855
                   bool rename_children)
836
856
{
 
857
        const char *error = NULL;
 
858
 
837
859
        if (!mailbox_list_is_valid_existing_name(src->list, src->name) ||
838
860
            *src->name == '\0' ||
839
861
            !mailbox_list_is_valid_create_name(dest->list, dest->name)) {
841
863
                                       "Invalid mailbox name");
842
864
                return -1;
843
865
        }
844
 
        if (!mail_storages_rename_compatible(src->storage, dest->storage) ||
845
 
            !mailbox_lists_rename_compatible(src->list, dest->list)) {
 
866
        if (!mail_storages_rename_compatible(src->storage,
 
867
                                             dest->storage, &error) ||
 
868
            !mailbox_lists_rename_compatible(src->list,
 
869
                                             dest->list, &error)) {
 
870
                if (src->storage->set->mail_debug) {
 
871
                        i_debug("Can't rename '%s' to '%s': %s",
 
872
                                src->vname, dest->vname, error);
 
873
                }
846
874
                mail_storage_set_error(src->storage, MAIL_ERROR_NOTPOSSIBLE,
847
875
                        "Can't rename mailboxes across specified storages.");
848
876
                return -1;