<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span><br></span></div><div><br></div><div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"><div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"><font face="Arial" size="2"><b><span style="font-weight:bold;"></span></b></font><div id="yiv1076030130"><div style="color:#000;background-color:#fff;font-family:times new roman, new york, times, serif;font-size:12pt;"><div style="font-family:times new roman, new york, times, serif;font-size:12pt;"><div style="font-family:times new roman, new york, times, serif;font-size:12pt;"><font face="Arial" size="2"><br></font>> Thanks Sebastian and Nicolas.<br>> <br>> The corrupt data has been found.<br>> <br>> You're right it was indeed in the huge file
~/.offlineimap/Repository-IMAPLocal<username>/UIDMapping/INBOX.Sent <br>> <br>> Here are a few lines before and after :<br>> 16731:4777<br>> 16732:4778<br>> 16733:4779<br>> 16734: P 35:4781<br>>
16736:4782<br>> 16737:4783<br>> 16738:4784<br>> They're consecutive UIDs so I re-entered them and filled in the missing numbers in the sequence.<br>> <br>> With the INBOX.Sent file repaired in this user, I re-ran it, and we're down to this same basic error on both mailboxes:<br>> <br>> <br>> "WARNING: ERROR in syncfolder for username1: null byte in argument for long()"<br>> "WARNING: ERROR in syncfolder for username2: null byte in argument for long()"<br>> <br>> <br>> Do you have a patch for this "ERROR in syncfolder", to pinpoint the line number and filename ?<br><br>The error most likely occurs in offlineimap/offlineimap/folder/IMAP.py<br>around line 162 in the cachemessagelist() function<br><br>What happens is that we select a folder in line 111 in:<br><br>imaptype, imapdata = imapobj.select(self.getfullname(), readonly = 1, force = 1)<br><br>and later in line 162 we go through the returned data, trying to get
the<br>highest UID number that the select call returned:<br><br> for msgid in imapdata:<br> maxmsgid = max(long(msgid), maxmsgid)<br><br>If you could add some debug code in the form<br><br> for msgid in imapdata:<br> try:<br> maxmsgid = max(long(msgid), maxmsgid)<br> except:<br> raise Exception(str(imapdata))<br><br>and let us see what exactly had been returned in imapdata we could try<br>to work this out.<br><br>Let me know if you need more help in making the code changes. I
hope we<br>get this one nailed down.<br><br>Sebastian<br><br>============<br><br>I'm on 6.3.2-0 because it's the highest that will run on debian 5.0 (lenny).<br><br>The catch is, 6.3.2-0 code for offlineimap/offlineimap/folder/IMAP.py is using imapobj not imapdata - so it seems like your patch would need modification to fit.<br><br>Here is the code excerpted from lines 175-188:<br><br> try:<br> # 1. Some mail servers do not return an EXISTS response<br> # if the folder is empty. 2. ZIMBRA servers can return<br> # multiple
EXISTS replies in the form 500, 1000, 1500,<br> # 1623 so check for potentially multiple replies.<br> maxmsgid = 0<br> for msgid in imapobj.untagged_responses['EXISTS']:<br> maxmsgid = max(long(msgid), maxmsgid)<br> messagesToFetch = '1:%d' % maxmsgid;<br> except
KeyError:<br> return<br> if maxmsgid < 1:<br> #no messages; return<br> return<br><br>Your suggestion on how to patch this ?<br><br>Chris<br></div></div></div></div><br>---------------------------------------------------------------<br><br>Sebastian, Nicolas,<br><br>I went ahead with your suggestion and patched those lines (in version 6.3.2-0 folder/IMAP.py ) by wrapping it with the try catch bock.<br><br>Running it triggered a recompile. <br><br>But it didn't output any further details on the filename/line number
where any bad data is. <br><br>Here's the patch just FYI, from line 174:<br><br> else:<br> try:<br> # 1. Some mail servers do not return an EXISTS response<br> # if the folder is empty. 2. ZIMBRA servers can return<br> # multiple EXISTS replies in the form 500, 1000, 1500,<br> # 1623 so check for potentially multiple
replies.<br> maxmsgid = 0<br> for msgid in imapobj.untagged_responses['EXISTS']:<br> try: #new<br> maxmsgid = max(long(msgid), maxmsgid)<br> except:
#new<br> raise Exception(str(imapobj)) #new<br> messagesToFetch = '1:%d' % maxmsgid;<br> except KeyError:<br> return<br> if maxmsgid < 1:<br> #no messages;
return<br> return<br> # Now, get the flags and UIDs for these.<br> # We could conceivably get rid of maxmsgid and just say<br> # '1:*' here.<br> response = imapobj.fetch(messagesToFetch, '(FLAGS UID)')[1]<br><br>Must get better info on where the bad data is located, and repair these 2 username's data, ASAP.<br><br>I see the actual error message gets output in the file offlineimap/accounts.py, function syncfolder, line 380:<br> except:<br> ui.warn("ERROR in syncfolder for %s folder %s: %s" %
\<br> (accountname,remotefolder.getvisiblename(),sys.exc_info()[1]))<br><br>These are available: localrepos, localfolder, remoterepos, remotefolder. <br><br>How about we output details of the line number and filename right here in the call to ui.warn ????<br><br>Chris<br><br></div></div></div></body></html>