rgrove / larch

:skull: Larch copies messages from one IMAP server to another. No longer maintained.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Duplicated folder. Gmail isn't case sensitive.

carloscabanero opened this issue · comments

This issue happens whenever you have a folder with the same name but different casing between source and destination (ie. "folder" - "Folder"). IMAP protocol is case sensitive, but gmail isn't and throws a fatal error that stops the migration.

I coded a simple patch that adds a new quirk, that checks a regexp for the name.

def mailbox(name, delim = '/')
    retries = 0

    name.gsub!(/^(inbox\/?)/i){ $1.upcase }
    name.gsub!(delim, self.delim)

    name.gsub!(/\s+/, ' ') if @quirks[:gmail]

    # Gmail doesn't allow folders with leading or trailing whitespace.                                                                                       \

    name.strip! if @quirks[:gmail]

    begin
      if @quirks[:gmail]
        # In Gmail folders are not case sensitive                                                                                                             
        update_mailboxes
        @mailboxes.keys.each do |key|
          if key =~ /^#{Regexp.quote(name)}$/i
            return @mailboxes[key]
          end
        end
        raise MailboxNotFoundError, "mailbox not found: #{name}"
      end

      @mailboxes.fetch(name) do
        update_mailboxes
[....]

Dupe issue. Ironic. :)