Fix mbox.select(foldername) readonly parameter comparison
The default parameter value was "None", and we were comparing that directly to the imaplib2 value of is_readonly which is False or True, so the comparison always returned "False". Fix this by setting the default parameter to "False" and not "None". Also convert all users of that function to use False/True. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> Conflicts: Changelog.draft.rst
This commit is contained in:
parent
5f5aec6114
commit
8b3ed8b004
@ -29,3 +29,7 @@ Bug Fixes
|
|||||||
|
|
||||||
* New folders on the remote would be skipped on the very sync run they
|
* New folders on the remote would be skipped on the very sync run they
|
||||||
are created and only by synced in subsequent runs. Fixed.
|
are created and only by synced in subsequent runs. Fixed.
|
||||||
|
|
||||||
|
* a readonly parameter to select() was not always treated correctly,
|
||||||
|
which could result in some folders being opened read-only when we
|
||||||
|
really needed read-write.
|
||||||
|
@ -55,7 +55,7 @@ class IMAPFolder(BaseFolder):
|
|||||||
try:
|
try:
|
||||||
imapobj.select(self.getfullname())
|
imapobj.select(self.getfullname())
|
||||||
except imapobj.readonly:
|
except imapobj.readonly:
|
||||||
imapobj.select(self.getfullname(), readonly = 1)
|
imapobj.select(self.getfullname(), readonly = True)
|
||||||
|
|
||||||
def suggeststhreads(self):
|
def suggeststhreads(self):
|
||||||
return 1
|
return 1
|
||||||
@ -205,7 +205,7 @@ class IMAPFolder(BaseFolder):
|
|||||||
fails_left = 2 # retry on dropped connection
|
fails_left = 2 # retry on dropped connection
|
||||||
while fails_left:
|
while fails_left:
|
||||||
try:
|
try:
|
||||||
imapobj.select(self.getfullname(), readonly = 1)
|
imapobj.select(self.getfullname(), readonly = True)
|
||||||
res_type, data = imapobj.uid('fetch', str(uid),
|
res_type, data = imapobj.uid('fetch', str(uid),
|
||||||
'(BODY.PEEK[])')
|
'(BODY.PEEK[])')
|
||||||
fails_left = 0
|
fails_left = 0
|
||||||
|
@ -34,25 +34,25 @@ except ImportError:
|
|||||||
#fails on python <2.6
|
#fails on python <2.6
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class UsefulIMAPMixIn:
|
class UsefulIMAPMixIn(object):
|
||||||
def getselectedfolder(self):
|
def getselectedfolder(self):
|
||||||
if self.state == 'SELECTED':
|
if self.state == 'SELECTED':
|
||||||
return self.mailbox
|
return self.mailbox
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def select(self, mailbox='INBOX', readonly=None, force = 0):
|
def select(self, mailbox='INBOX', readonly=False, force = 0):
|
||||||
"""Selects a mailbox on the IMAP server
|
"""Selects a mailbox on the IMAP server
|
||||||
|
|
||||||
:returns: 'OK' on success, nothing if the folder was already
|
:returns: 'OK' on success, nothing if the folder was already
|
||||||
selected or raises an :exc:`OfflineImapError`"""
|
selected or raises an :exc:`OfflineImapError`"""
|
||||||
if (not force) and self.getselectedfolder() == mailbox \
|
if self.getselectedfolder() == mailbox and self.is_readonly == readonly \
|
||||||
and self.is_readonly == readonly:
|
and not force:
|
||||||
# No change; return.
|
# No change; return.
|
||||||
return
|
return
|
||||||
# Wipe out all old responses, to maintain semantics with old imaplib2
|
# Wipe out all old responses, to maintain semantics with old imaplib2
|
||||||
del self.untagged_responses[:]
|
del self.untagged_responses[:]
|
||||||
try:
|
try:
|
||||||
result = self.__class__.__bases__[1].select(self, mailbox, readonly)
|
result = super(UsefulIMAPMixIn, self).select(mailbox, readonly)
|
||||||
except self.abort, e:
|
except self.abort, e:
|
||||||
# self.abort is raised when we are supposed to retry
|
# self.abort is raised when we are supposed to retry
|
||||||
errstr = "Server '%s' closed connection, error on SELECT '%s'. Ser"\
|
errstr = "Server '%s' closed connection, error on SELECT '%s'. Ser"\
|
||||||
|
@ -290,7 +290,7 @@ class IMAPRepository(BaseRepository):
|
|||||||
try:
|
try:
|
||||||
for foldername in self.folderincludes:
|
for foldername in self.folderincludes:
|
||||||
try:
|
try:
|
||||||
imapobj.select(foldername, readonly = 1)
|
imapobj.select(foldername, readonly = True)
|
||||||
except OfflineImapError, e:
|
except OfflineImapError, e:
|
||||||
# couldn't select this folderinclude, so ignore folder.
|
# couldn't select this folderinclude, so ignore folder.
|
||||||
if e.severity > OfflineImapError.ERROR.FOLDER:
|
if e.severity > OfflineImapError.ERROR.FOLDER:
|
||||||
|
Loading…
Reference in New Issue
Block a user