/offlineimap/head: changeset 471
- Added some significant debug code to folder/IMAP.py when saving a new message with APPEND. This should make it easier to track down bugs both in OfflineIMAP and in mail servers that implement this poorly. - Fixed adding of X-OfflineIMAP header when the message starts out with no headers. (This should not generally occur.) This should help with some "invalid literal for long()" problems.
This commit is contained in:
parent
7ddce0b57d
commit
5454489a16
@ -5,8 +5,14 @@ offlineimap (3.99.16) unstable; urgency=low
|
|||||||
scan ., resulting in huge paths and an eventual crash. Fixed with
|
scan ., resulting in huge paths and an eventual crash. Fixed with
|
||||||
a one-line patch to Maildir.py. Fixes [complete.org #60].
|
a one-line patch to Maildir.py. Fixes [complete.org #60].
|
||||||
Closes: #191318.
|
Closes: #191318.
|
||||||
|
* Added some significant debug code to folder/IMAP.py when saving a new
|
||||||
|
message with APPEND. This should make it easier to track down bugs both
|
||||||
|
in OfflineIMAP and in mail servers that implement this poorly.
|
||||||
|
* Fixed adding of X-OfflineIMAP header when the message starts out with
|
||||||
|
no headers. (This should not generally occur.) This should help
|
||||||
|
with some "invalid literal for long()" problems.
|
||||||
|
|
||||||
-- John Goerzen <jgoerzen@complete.org> Tue, 29 Apr 2003 08:10:17 -0500
|
-- John Goerzen <jgoerzen@complete.org> Tue, 6 May 2003 07:10:17 -0500
|
||||||
|
|
||||||
offlineimap (3.99.15) unstable; urgency=low
|
offlineimap (3.99.15) unstable; urgency=low
|
||||||
|
|
||||||
|
@ -122,13 +122,28 @@ class IMAPFolder(BaseFolder):
|
|||||||
return (headername, headervalue)
|
return (headername, headervalue)
|
||||||
|
|
||||||
def savemessage_addheader(self, content, headername, headervalue):
|
def savemessage_addheader(self, content, headername, headervalue):
|
||||||
|
ui = UIBase.getglobalui()
|
||||||
|
ui.debug('imap',
|
||||||
|
'savemessage_addheader: called to add %s: %s' % (headername,
|
||||||
|
headervalue))
|
||||||
insertionpoint = content.find("\r\n")
|
insertionpoint = content.find("\r\n")
|
||||||
|
ui.debug('imap', 'savemessage_addheader: insertionpoint = %d' % insertionpoint)
|
||||||
leader = content[0:insertionpoint]
|
leader = content[0:insertionpoint]
|
||||||
newline = "\r\n%s: %s" % (headername, headervalue)
|
ui.debug('imap', 'savemessage_addheader: leader = %s' % repr(leader))
|
||||||
|
if insertionpoint == 0:
|
||||||
|
newline = ''
|
||||||
|
else:
|
||||||
|
newline = "\r\n"
|
||||||
|
newline += "%s: %s" % (headername, headervalue)
|
||||||
|
ui.debug('imap', 'savemessage_addheader: newline = ' + repr(newline))
|
||||||
trailer = content[insertionpoint:]
|
trailer = content[insertionpoint:]
|
||||||
|
ui.debug('imap', 'savemessage_addheader: trailer = ' + repr(trailer))
|
||||||
return leader + newline + trailer
|
return leader + newline + trailer
|
||||||
|
|
||||||
def savemessage_searchforheader(self, imapobj, headername, headervalue):
|
def savemessage_searchforheader(self, imapobj, headername, headervalue):
|
||||||
|
ui = UIBase.getglobalui()
|
||||||
|
ui.debug('imap', 'savemessage_searchforheader called for %s: %s' % \
|
||||||
|
(headername, headervalue))
|
||||||
# Now find the UID it got.
|
# Now find the UID it got.
|
||||||
headervalue = imapobj._quote(headervalue)
|
headervalue = imapobj._quote(headervalue)
|
||||||
try:
|
try:
|
||||||
@ -137,7 +152,11 @@ class IMAPFolder(BaseFolder):
|
|||||||
except imapobj.error:
|
except imapobj.error:
|
||||||
# IMAP server doesn't implement search or had a problem.
|
# IMAP server doesn't implement search or had a problem.
|
||||||
return 0
|
return 0
|
||||||
|
ui.debug('imap', 'savemessage_searchforheader got initial matchinguids: ' + repr(matchinguids))
|
||||||
|
|
||||||
matchinguids = matchinguids.split(' ')
|
matchinguids = matchinguids.split(' ')
|
||||||
|
ui.debug('imap', 'savemessage_searchforheader: matchinguids now ' + \
|
||||||
|
repr(matchinguids))
|
||||||
if len(matchinguids) != 1 or matchinguids[0] == None:
|
if len(matchinguids) != 1 or matchinguids[0] == None:
|
||||||
raise ValueError, "While attempting to find UID for message with header %s, got wrong-sized matchinguids of %s" % (headername, str(matchinguids))
|
raise ValueError, "While attempting to find UID for message with header %s, got wrong-sized matchinguids of %s" % (headername, str(matchinguids))
|
||||||
matchinguids.sort()
|
matchinguids.sort()
|
||||||
@ -145,11 +164,13 @@ class IMAPFolder(BaseFolder):
|
|||||||
|
|
||||||
def savemessage(self, uid, content, flags):
|
def savemessage(self, uid, content, flags):
|
||||||
imapobj = self.imapserver.acquireconnection()
|
imapobj = self.imapserver.acquireconnection()
|
||||||
|
ui = UIBase.getglobalui()
|
||||||
|
ui.debug('imap', 'savemessage: called')
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
imapobj.select(self.getfullname()) # Needed for search
|
imapobj.select(self.getfullname()) # Needed for search
|
||||||
except imapobj.readonly:
|
except imapobj.readonly:
|
||||||
UIBase.getglobalui().msgtoreadonly(self, uid, content, flags)
|
ui.msgtoreadonly(self, uid, content, flags)
|
||||||
# Return indicating message taken, but no UID assigned.
|
# Return indicating message taken, but no UID assigned.
|
||||||
# Fudge it.
|
# Fudge it.
|
||||||
return 0
|
return 0
|
||||||
@ -174,11 +195,18 @@ class IMAPFolder(BaseFolder):
|
|||||||
# but some IMAP servers nonetheless choke on 1902.
|
# but some IMAP servers nonetheless choke on 1902.
|
||||||
date = imaplib.Time2Internaldate(time.localtime())
|
date = imaplib.Time2Internaldate(time.localtime())
|
||||||
|
|
||||||
|
ui.debug('imap', 'savemessage: using date ' + str(date))
|
||||||
content = re.sub("(?<!\r)\n", "\r\n", content)
|
content = re.sub("(?<!\r)\n", "\r\n", content)
|
||||||
|
ui.debug('imap', 'savemessage: initial content is: ' + repr(content))
|
||||||
|
|
||||||
(headername, headervalue) = self.savemessage_getnewheader(content)
|
(headername, headervalue) = self.savemessage_getnewheader(content)
|
||||||
|
ui.debug('imap', 'savemessage: new headers are: %s: %s' % \
|
||||||
|
(headername, headervalue))
|
||||||
content = self.savemessage_addheader(content, headername,
|
content = self.savemessage_addheader(content, headername,
|
||||||
headervalue)
|
headervalue)
|
||||||
|
ui.debug('imap', 'savemessage: new content is: ' + repr(content))
|
||||||
|
ui.debug('imap', 'savemessage: new content length is ' + \
|
||||||
|
str(len(content)))
|
||||||
|
|
||||||
assert(imapobj.append(self.getfullname(),
|
assert(imapobj.append(self.getfullname(),
|
||||||
imaputil.flagsmaildir2imap(flags),
|
imaputil.flagsmaildir2imap(flags),
|
||||||
@ -189,9 +217,11 @@ class IMAPFolder(BaseFolder):
|
|||||||
|
|
||||||
# Keep trying until we get the UID.
|
# Keep trying until we get the UID.
|
||||||
try:
|
try:
|
||||||
|
ui.debug('imap', 'savemessage: first attempt to get new UID')
|
||||||
uid = self.savemessage_searchforheader(imapobj, headername,
|
uid = self.savemessage_searchforheader(imapobj, headername,
|
||||||
headervalue)
|
headervalue)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
ui.debug('imap', 'savemessage: first attempt to get new UID failed. Going to run a NOOP and try again.')
|
||||||
assert(imapobj.noop()[0] == 'OK')
|
assert(imapobj.noop()[0] == 'OK')
|
||||||
uid = self.savemessage_searchforheader(imapobj, headername,
|
uid = self.savemessage_searchforheader(imapobj, headername,
|
||||||
headervalue)
|
headervalue)
|
||||||
@ -199,6 +229,7 @@ class IMAPFolder(BaseFolder):
|
|||||||
self.imapserver.releaseconnection(imapobj)
|
self.imapserver.releaseconnection(imapobj)
|
||||||
|
|
||||||
self.messagelist[uid] = {'uid': uid, 'flags': flags}
|
self.messagelist[uid] = {'uid': uid, 'flags': flags}
|
||||||
|
ui.debug('imap', 'savemessage: returning %d' % uid)
|
||||||
return uid
|
return uid
|
||||||
|
|
||||||
def savemessageflags(self, uid, flags):
|
def savemessageflags(self, uid, flags):
|
||||||
|
Loading…
Reference in New Issue
Block a user