[PATCH] More detailed error output on corrupt UID mapping files

chris coleman christocoleman at yahoo.com
Mon May 2 15:52:22 BST 2011

Thanks Sebastian and Nicolas.

The corrupt data has been found.

You're right it was indeed in the huge file ~/.offlineimap/Repository-IMAPLocal<username>/UIDMapping/INBOX.Sent  

Here are a few lines before and after :
16734:  P    35:4781
They're consecutive UIDs so I re-entered them and filled in the missing numbers in the sequence.

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:

"WARNING: ERROR in syncfolder for username1: null byte in argument for long()"
"WARNING: ERROR in syncfolder for username2: null byte in argument for long()"

Do you have a patch for this "ERROR in syncfolder", to pinpoint the line number and filename ?



This function will need much more "robustifying", but the very least we
can do is to print the file name and line that are giving trouble.

Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
Chris, you might want to try this patch to see the exact file name and line
that are giving you trouble. Nicolas, I advocate this one for going into master :-)

Changelog.draft.rst           |    1 +
offlineimap/folder/UIDMaps.py |    6 +++++-
2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/Changelog.draft.rst b/Changelog.draft.rst
index d0125b7..11d16ee 100644
--- a/Changelog.draft.rst
+++ b/Changelog.draft.rst
@@ -18,6 +18,7 @@ Changes

- no whitespace is stripped from comma-separated arguments passed via
   the -f option.
+- give more detailed error when encountering a corrupt UID mapping file

Bug Fixes
diff --git a/offlineimap/folder/UIDMaps.py b/offlineimap/folder/UIDMaps.py
index 43b28e4..e87e21e 100644
--- a/offlineimap/folder/UIDMaps.py
+++ b/offlineimap/folder/UIDMaps.py
@@ -51,7 +51,11 @@ class MappingFolderMixIn:
                 line = file.readline()
                 if not len(line):
-                line = line.strip()
+                try:
+                    line = line.strip()
+                except ValueError:
+                    raise Exception("Corrupt line '%s' in UID mapping file '%s'" \
+                                        %(line, mapfilename))
                 (str1, str2) = line.split(':')
                 loc = long(str1)
                 rem = long(str2)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/offlineimap-project/attachments/20110502/53280d72/attachment-0001.html>

More information about the OfflineIMAP-project mailing list