проблема с rename
parent
4547c85237
commit
9956b94649
19
mech_imap.py
19
mech_imap.py
|
@ -82,7 +82,7 @@ class IMAPUserAccount(object):
|
||||||
if pathspec in conf.imap_auto_mbox:
|
if pathspec in conf.imap_auto_mbox:
|
||||||
raise imap4.MailboxException, pathspec
|
raise imap4.MailboxException, pathspec
|
||||||
if pathspec not in IMAP_MBOX_REG[self.dir].keys():
|
if pathspec not in IMAP_MBOX_REG[self.dir].keys():
|
||||||
raise imap4.MailboxException("No such mailbox")
|
raise imap4.NoSuchMailbox, pathspec
|
||||||
inferiors = self._inferiorNames(pathspec)
|
inferiors = self._inferiorNames(pathspec)
|
||||||
if r'\Noselect' in IMAP_MBOX_REG[self.dir][pathspec].getFlags():
|
if r'\Noselect' in IMAP_MBOX_REG[self.dir][pathspec].getFlags():
|
||||||
# Check for hierarchically inferior mailboxes with this one
|
# Check for hierarchically inferior mailboxes with this one
|
||||||
|
@ -111,19 +111,22 @@ class IMAPUserAccount(object):
|
||||||
if new in IMAP_MBOX_REG[self.dir].keys():
|
if new in IMAP_MBOX_REG[self.dir].keys():
|
||||||
raise imap4.MailboxCollision, new
|
raise imap4.MailboxCollision, new
|
||||||
for (old, new) in inferiors:
|
for (old, new) in inferiors:
|
||||||
move(os.path.join(self.dir, old), os.path.join(self.dir, new))
|
m = IMAP_MBOX_REG[self.dir][old]
|
||||||
IMAP_MBOX_REG[self.dir][new] = IMAP_MBOX_REG[self.dir][old]
|
|
||||||
IMAP_MBOX_REG[self.dir][new].path = os.path.join(self.dir, new)
|
|
||||||
IMAP_MBOX_REG[self.dir][new].path_msg_info = os.path.join(self.dir, conf.imap_msg_info)
|
|
||||||
IMAP_MBOX_REG[self.dir][new].path_mbox_info = os.path.join(self.dir, conf.imap_mbox_info)
|
|
||||||
del IMAP_MBOX_REG[self.dir][old]
|
del IMAP_MBOX_REG[self.dir][old]
|
||||||
return True
|
for l in m.listeners: m.listeners.remove(l)
|
||||||
|
m.close()
|
||||||
|
move(os.path.join(self.dir, old), os.path.join(self.dir, new))
|
||||||
|
IMAP_MBOX_REG[self.dir][new] = self._getMailbox(new)
|
||||||
|
IMAP_MBOX_REG[self.dir][new].subscribe()
|
||||||
|
return IMAP_MBOX_REG[self.dir][newname]
|
||||||
|
|
||||||
def subscribe(self, name):
|
def subscribe(self, name):
|
||||||
if isinstance(name, unicode):
|
if isinstance(name, unicode):
|
||||||
name = name.encode('imap4-utf-7')
|
name = name.encode('imap4-utf-7')
|
||||||
if name in IMAP_MBOX_REG[self.dir].keys():
|
if name in IMAP_MBOX_REG[self.dir].keys():
|
||||||
IMAP_MBOX_REG[self.dir][name].subscribe()
|
IMAP_MBOX_REG[self.dir][name].subscribe()
|
||||||
|
return True
|
||||||
|
raise imap4.NoSuchMailbox, name
|
||||||
|
|
||||||
def unsubscribe(self, name):
|
def unsubscribe(self, name):
|
||||||
if name in conf.imap_auto_mbox:
|
if name in conf.imap_auto_mbox:
|
||||||
|
@ -132,6 +135,8 @@ class IMAPUserAccount(object):
|
||||||
name = name.encode('imap4-utf-7')
|
name = name.encode('imap4-utf-7')
|
||||||
if name in IMAP_MBOX_REG[self.dir].keys():
|
if name in IMAP_MBOX_REG[self.dir].keys():
|
||||||
IMAP_MBOX_REG[self.dir][name].unsubscribe()
|
IMAP_MBOX_REG[self.dir][name].unsubscribe()
|
||||||
|
return True
|
||||||
|
raise imap4.NoSuchMailbox, name
|
||||||
|
|
||||||
def isSubscribed(self, name):
|
def isSubscribed(self, name):
|
||||||
if isinstance(name, unicode):
|
if isinstance(name, unicode):
|
||||||
|
|
|
@ -10,7 +10,7 @@ from threading import Thread
|
||||||
|
|
||||||
import random
|
import random
|
||||||
import email
|
import email
|
||||||
from pickle import load, dump
|
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class SerpentAppendMessageTask(maildir._MaildirMailboxAppendMessageTask):
|
||||||
try:
|
try:
|
||||||
self.osrename(self.tmpname, newname)
|
self.osrename(self.tmpname, newname)
|
||||||
break
|
break
|
||||||
except OSError, (err, estr):
|
except OSError, (err, _):
|
||||||
import errno
|
import errno
|
||||||
# if the newname exists, retry with a new newname.
|
# if the newname exists, retry with a new newname.
|
||||||
if err != errno.EEXIST:
|
if err != errno.EEXIST:
|
||||||
|
@ -94,7 +94,7 @@ class IMAPMailbox(ExtendedMaildir):
|
||||||
l = [l for l in self.__msg_list_()]
|
l = [l for l in self.__msg_list_()]
|
||||||
for i in l:
|
for i in l:
|
||||||
fn = i.split('/')[-1]
|
fn = i.split('/')[-1]
|
||||||
if fn not in msg_info.keys():
|
if fn not in self.msg_info.keys():
|
||||||
val1 = {'uid': self.getUIDNext()}
|
val1 = {'uid': self.getUIDNext()}
|
||||||
if i.split('/')[-2] == 'new':
|
if i.split('/')[-2] == 'new':
|
||||||
val1['flags'] = []
|
val1['flags'] = []
|
||||||
|
@ -223,7 +223,7 @@ class IMAPMailbox(ExtendedMaildir):
|
||||||
new_path = os.path.join(self.path, 'cur', filename)
|
new_path = os.path.join(self.path, 'cur', filename)
|
||||||
os.rename(path, new_path)
|
os.rename(path, new_path)
|
||||||
d[_id] = self.msg_info[filename]['flags']
|
d[_id] = self.msg_info[filename]['flags']
|
||||||
msg_info.commit(blocking=False)
|
self.msg_info.commit(blocking=False)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def expunge(self):
|
def expunge(self):
|
||||||
|
@ -258,7 +258,9 @@ class IMAPMailbox(ExtendedMaildir):
|
||||||
self.notifier.stopReading()
|
self.notifier.stopReading()
|
||||||
self.notifier.loseConnection()
|
self.notifier.loseConnection()
|
||||||
if conf.imap_expunge_on_close:
|
if conf.imap_expunge_on_close:
|
||||||
l = self.expunge()
|
self.expunge()
|
||||||
|
self.mbox_info.close()
|
||||||
|
self.msg_info.close()
|
||||||
|
|
||||||
class MaildirMessagePart(object):
|
class MaildirMessagePart(object):
|
||||||
implements(imap4.IMessagePart)
|
implements(imap4.IMessagePart)
|
||||||
|
|
Loading…
Reference in New Issue