asyncio
inpos 2016-05-29 17:01:58 +03:00
parent 3b1735aaef
commit 1378cef1f5
1 changed files with 19 additions and 19 deletions

View File

@ -201,26 +201,26 @@ class IMAPMailbox(ExtendedMaildir):
messagesToFetch = self._seqMessageSetToSeqDict(messages) messagesToFetch = self._seqMessageSetToSeqDict(messages)
return messagesToFetch return messagesToFetch
def store(self, messages, flags, mode, uid): def store(self, messages, flags, mode, uid):
self.__load_flags_()
d = {} d = {}
with SqliteDict(self.path_msg_info) as msg_info:
for _id, path in self.__fetch_(messages, uid).iteritems(): for _id, path in self.__fetch_(messages, uid).iteritems():
filename = path.split('/')[-1] filename = path.split('/')[-1]
if mode < 0: if mode < 0:
old_f = self.flags['flags'][filename] old_f = msg_info[filename]['flags']
self.flags['flags'][filename] = list(set(old_f).difference(set(flags))) msg_info[filename]['flags'] = list(set(old_f).difference(set(flags)))
if misc.IMAP_FLAGS['SEEN'] in flags and path.split('/')[-2] != 'new': if misc.IMAP_FLAGS['SEEN'] in flags and path.split('/')[-2] != 'new':
new_path = os.path.join(self.path, 'new', filename) new_path = os.path.join(self.path, 'new', filename)
os.rename(path, new_path) os.rename(path, new_path)
elif mode == 0: elif mode == 0:
self.flags["flags"][filename] = flags msg_info[filename]['flags'] = flags
elif mode > 0: elif mode > 0:
old_f = self.flags['flags'][filename] old_f = msg_info[filename]['flags']
self.flags['flags'][filename] = list(set(old_f).union(set(flags))) msg_info[filename]['flags'] = list(set(old_f).union(set(flags)))
if misc.IMAP_FLAGS['SEEN'] in flags and path.split('/')[-2] != 'cur': if misc.IMAP_FLAGS['SEEN'] in flags and path.split('/')[-2] != 'cur':
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)
self._save_flags() d[_id] = msg_info[filename]['flags']
d[_id] = self.flags['flags'][filename] msg_info.commit()
return d return d
def expunge(self): def expunge(self):