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