Перелал счётчики
parent
0a34f252d4
commit
8f88a79980
18
mech_imap.py
18
mech_imap.py
|
@ -217,25 +217,7 @@ class IMAPServerProtocol(imap4.IMAP4Server):
|
|||
except:
|
||||
#log.err()
|
||||
raise imap4.IllegalMailboxEncoding(name)
|
||||
|
||||
def do_CLOSE(self, tag):
|
||||
d = None
|
||||
cmbx = imap4.ICloseableMailbox(self.mbox, None)
|
||||
if cmbx is not None:
|
||||
d = imap4.maybeDeferred(cmbx.close)
|
||||
if d is not None:
|
||||
d.addCallbacks(self.__cbClose, self.__ebClose, (tag,), None, (tag,), None)
|
||||
else:
|
||||
self.__cbClose(None, tag)
|
||||
|
||||
select_CLOSE = (do_CLOSE,)
|
||||
|
||||
def __cbClose(self, result, tag):
|
||||
self.sendPositiveResponse(tag, 'CLOSE completed')
|
||||
self.mbox.removeListener(self)
|
||||
self.mbox = None
|
||||
self.state = 'auth'
|
||||
|
||||
def _cbCopySelectedMailbox(self, mbox, tag, messages, mailbox, uid):
|
||||
if not isinstance(mbox, IMAPMailbox):
|
||||
self.sendNegativeResponse(tag, 'No such mailbox: ' + mailbox)
|
||||
|
|
|
@ -69,7 +69,8 @@ class MailDirStore(object):
|
|||
inbox = os.path.join(mdir, 'INBOX')
|
||||
mailbox = self.mbox.IMAPMailbox(inbox)
|
||||
try:
|
||||
mailbox.addMessage(message, [IMAP_FLAGS['RECENT']])
|
||||
#mailbox.addMessage(message, [IMAP_FLAGS['RECENT']])
|
||||
mailbox.addMessage(message, [])
|
||||
return True
|
||||
except:
|
||||
raise
|
||||
|
|
|
@ -92,8 +92,10 @@ class IMAPMailbox(ExtendedMaildir):
|
|||
|
||||
def _new_files(self, wo, path, code):
|
||||
if code == inotify.IN_MOVED_TO or code == inotify.IN_DELETE:
|
||||
c = self.getMessageCount()
|
||||
r = self.getRecentCount()
|
||||
for l in self.listeners:
|
||||
l.newMessages(self.getMessageCount(), self.getRecentCount())
|
||||
l.newMessages(c, r)
|
||||
|
||||
def __check_flags_(self):
|
||||
if 'subscribed' not in self.mbox_info.keys(): self.mbox_info['subscribed'] = False
|
||||
|
@ -101,6 +103,7 @@ class IMAPMailbox(ExtendedMaildir):
|
|||
if 'special' not in self.mbox_info.keys(): self.mbox_info['special'] = ''
|
||||
if 'uidvalidity' not in self.mbox_info.keys(): self.mbox_info['uidvalidity'] = random.randint(0, 2**32)
|
||||
if 'uidnext' not in self.mbox_info.keys(): self.mbox_info['uidnext'] = 1
|
||||
if 'recent' not in self.mbox_info.keys(): self.mbox_info['recent'] = []
|
||||
#self.mbox_info.commit(blocking=False) # XXX
|
||||
l = [l for l in self.__msg_list_()]
|
||||
for i in l:
|
||||
|
@ -167,16 +170,19 @@ class IMAPMailbox(ExtendedMaildir):
|
|||
return sum(1 for flags in self.msg_flags.itervalues() if misc.IMAP_FLAGS['DELETED'] not in flags)
|
||||
|
||||
def getRecentCount(self):
|
||||
c = 0
|
||||
for m_items in self.msg_flags.iteritems():
|
||||
if misc.IMAP_FLAGS['RECENT'] in m_items[1]:
|
||||
c += 1
|
||||
self.msg_flags[m_items[0]] = list(set(m_items[1]).difference(set([misc.IMAP_FLAGS['RECENT']])))
|
||||
#self.msg_info.commit(blocking=False) # XXX
|
||||
#c = 0
|
||||
#for m_items in self.msg_flags.iteritems():
|
||||
# if misc.IMAP_FLAGS['RECENT'] in m_items[1]:
|
||||
# c += 1
|
||||
# self.msg_flags[m_items[0]] = list(set(m_items[1]).difference(set([misc.IMAP_FLAGS['RECENT']])))
|
||||
##self.msg_info.commit(blocking=False) # XXX
|
||||
c = len(self.mbox_info['recent'])
|
||||
if c > 0:
|
||||
self.mbox_info['recent'] = []
|
||||
return c
|
||||
|
||||
def getUnseenCount(self):
|
||||
return self.getMessageCount() - self.__count_flagged_msgs_(misc.IMAP_FLAGS['SEEN'])
|
||||
return sum(1 for flags in self.msg_flags.itervalues() if misc.IMAP_FLAGS['SEEN'] not in flags)
|
||||
|
||||
def isWriteable(self):
|
||||
return True
|
||||
|
@ -206,6 +212,7 @@ class IMAPMailbox(ExtendedMaildir):
|
|||
if misc.IMAP_FLAGS['SEEN'] in flags and path.split('/')[-2] != 'cur':
|
||||
new_path = os.path.join(self.path, 'cur', fn)
|
||||
os.rename(path, new_path)
|
||||
self.mbox_info['recent'] = list(set(self.mbox_info['recent']).union(set([fn])))
|
||||
|
||||
def __msg_list_(self):
|
||||
a = []
|
||||
|
@ -303,9 +310,6 @@ class IMAPMailbox(ExtendedMaildir):
|
|||
self._stop_monitor()
|
||||
if conf.imap_expunge_on_close:
|
||||
self.expunge()
|
||||
self.msg_uids.close()
|
||||
self.msg_flags.close()
|
||||
self.mbox_info.close()
|
||||
self.closed = True
|
||||
|
||||
class MaildirMessagePart(object):
|
||||
|
|
Loading…
Reference in New Issue