offlineimap3 icon indicating copy to clipboard operation
offlineimap3 copied to clipboard

Cannot handle 'already exists' and 'Cannot create this folder' messages when syncing folders with Courier IMAP

Open RigacciOrg opened this issue 1 year ago • 1 comments

General informations

  • system/distribution (with version): Debian GNU/Linux 12.4
  • offlineimap version (offlineimap -V): offlineimap v8.0.0, imaplib2 v3.05, Python v3.11.2, OpenSSL 3.0.11 19 Sep 2023
  • Python version: 3.11.2
  • CLI options:
  • Courier IMAP: 5.0.13

Configuration file offlineimaprc

[general]
accounts = CopyFromIMAP

[Account CopyFromIMAP]
remoterepository = OldServer
localrepository = Ipbox

[Repository OldServer]
type = IMAP
nametrans = lambda foldername: re.sub(r'^INBOX\/$', 'INBOX', 'INBOX/' + re.sub(r'(^INBOX$)|(^INBOX\.)', '', foldername))
remotehost = RemoteHost
remoteuser = RemoteUser
remotepass = MySecret
createfolders = False
sslcacertfile = /usr/share/ca-certificates/mozilla/ISRG_Root_X1.crt

[Repository Ipbox]
type = IMAP
remotehost = 127.0.0.1
remoteuser = LocalUser
remotepass = MySecret
sslcacertfile = /usr/share/ca-certificates/mozilla/ISRG_Root_X1.crt

pythonfile (if any)

Logs, error

Without the patch https://github.com/OfflineIMAP/offlineimap/pull/646/commits/5943e13737ebf1086a1adff6f8d2299324110d0a the error rises when syncing the first subdirectory (e.g. INBOX.Archive):

 Creating folder INBOX[Ipbox]
 ERROR: Creating folder INBOX.Archive on repository Ipbox
  Folder 'INBOX'[Ipbox] could not be created. Server responded: ('NO', [b'INBOX already exists!'])
 ERROR: Folder 'INBOX'[Ipbox] could not be created. Server responded: ('NO', [b'INBOX already exists!'])

After applying the patch https://github.com/OfflineIMAP/offlineimap/pull/646/commits/5943e13737ebf1086a1adff6f8d2299324110d0a the error rises at the second level subdirectory (e.g. INBOX.Archive.2013):

 Creating folder INBOX[Ipbox]
 Creating folder INBOX.Archives[Ipbox]
 ERROR: Creating folder INBOX.Archives.2013 on repository Ipbox
  Folder 'INBOX.Archives'[Ipbox] could not be created. Server responded: ('NO', [b'Cannot create this folder.'])
 ERROR: Folder 'INBOX.Archives'[Ipbox] could not be created. Server responded: ('NO', [b'Cannot create this folder.'])

Steps to reproduce the error

  • Configure offlineimap3 to syncronize between two IMAP accounts.
  • The receiving IMAP account is hadled by the Courier IMAP server 5.0.13.
  • In the source IMAP account has a subfolder and a sub-subfolder.
  • Run offlineimap to syncronize source with destination.
  • The program crashe at the first subfolder, e.g. INBOX.Archive.
  • Apply the patch 5943e13737ebf1086a1adff6f8d2299324110d0a and re-run offlineimap.
  • The program crashe at the first subfolder, e.g. INBOX.Archive.2013.

As you can see in the following IMAP session, the Courier IMAP server responds with different messages when creating an already existing subfolder, depending on the subfolder depth:

AAA1 LIST "" "*"
* LIST (\HasNoChildren) "." "INBOX.Archives.2013"
* LIST (\HasNoChildren) "." "INBOX.Sent"
* LIST (\HasChildren) "." "INBOX.Archives"
* LIST (\HasNoChildren) "." "INBOX.Trash"
* LIST (\HasNoChildren) "." "INBOX.Archive"
* LIST (\Unmarked \HasChildren) "." "INBOX"
* LIST (\HasNoChildren) "." "INBOX.Drafts"
* LIST (\HasNoChildren) "." "INBOX.Spam"
AAA1 OK LIST completed
AAA2 CREATE INBOX
AAA2 NO INBOX already exists!
AAA3 CREATE INBOX.Archives
AAA3 NO Cannot create this folder.
AAA4 CREATE INBOX.Archives.2024
AAA4 OK "INBOX.Archives.2024" created.
AAA5 CREATE INBOX.Archives.2024
AAA5 NO Cannot create this folder.

The problem is that offlineimap is programmed to only ignore errors containing the string [ALREADYEXISTS]. Errors containing the already exists! and Cannot create this folder strings are instead raised.

The the already exists! problem is the same reported by issue #130.

RigacciOrg avatar Mar 21 '24 11:03 RigacciOrg

Hi,

I applied the patch "Merge pull request https://github.com/OfflineIMAP/offlineimap3/pull/178 from roboshim/dont-create-existing-folder". This patch solves this problem?

Regards, kix

thekix avatar Aug 15 '24 19:08 thekix