[PATCH] Offlineimap and Gnus
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
[I tried sending this a week or so ago, but it didn't seem to make it
to the list... retrying with a different From: address...]
So the nnmaildir backend in Gnus doesn't use proper maildir flags on
the files. Instead, it makes a subdirectory for each flag
..nnmaildir/marks/<markname> which contains empty files to indicate
the presence of a flag. The patch below makes offlineimap read and
write nnmaildir marks rather than maildir flags if the marks directory
exists in a particular folder.
Sorry if the coding style is a bit off -- this is the first time I've
coded in Python. And I guess this should really be protected by a
configuration option, but I found that bit of the code too hard to
follow ;-)
--- folder/Maildir.py.orig 2003-06-18 16:28:22.000000000 +0100
+++ folder/Maildir.py 2003-09-05 11:48:06.000000000 +0100
@@ -26,6 +26,11 @@
uidmatchre = re.compile(',U=(\d+)')
flagmatchre = re.compile(':.*2,([A-Z]+)')
+marktoflagmap = [('expire','T'),\
+ ('read','S'),\
+ ('reply','R'),\
+ ('forward','R'),\
+ ('tick','F')]
timeseq = 0
lasttime = long(0)
timelock = Lock()
@@ -101,11 +106,21 @@
nouidcounter -= 1
else:
uid = long(uidmatch.group(1))
- flagmatch = flagmatchre.search(messagename)
+
flags = []
- if flagmatch:
- flags = [x for x in flagmatch.group(1)]
+ markdir = os.path.join(self.getfullname(), '.nnmaildir', 'marks')
+ if os.path.exists(markdir): # Look for gnus-style flags
+ basename = messagename.split(':')[0]
+ for markflag in marktoflagmap:
+ markname = os.path.join(markdir, markflag[0], basename)
+ if os.path.exists(markname):
+ flags.append(markflag[1])
+ else: # Use proper maildir-style flags
+ flagmatch = flagmatchre.search(messagename)
+ if flagmatch:
+ flags = [x for x in flagmatch.group(1)]
flags.sort()
+
retval[uid] = {'uid': uid,
'flags': flags,
'filename': file}
@@ -188,22 +203,40 @@
newpath = os.path.join(self.getfullname(), 'cur')
else:
newpath = os.path.join(self.getfullname(), 'new')
- infostr = ':'
infomatch = re.search('(:.*)$', newname)
if infomatch: # If the info string is present..
- infostr = infomatch.group(1)
- newname = newname.split(':')[0] # Strip off the info string.
- infostr = re.sub('2,[A-Z]*', '', infostr)
+ infostr = re.sub('2,[A-Z]*', '', infomatch.group(1))
+ basename = newname.split(':')[0] # Strip off the info string.
+ else:
+ infostr = ':'
+ basename = newname
flags.sort()
infostr += '2,' + ''.join(flags)
- newname += infostr
+ newname = basename + infostr
newfilename = os.path.join(newpath, newname)
if (newfilename != oldfilename):
os.rename(oldfilename, newfilename)
self.messagelist[uid]['flags'] = flags
self.messagelist[uid]['filename'] = newfilename
-
+
+ markdir = os.path.join(self.getfullname(), '.nnmaildir', 'marks')
+ ui = UIBase.getglobalui()
+ if os.path.exists(markdir):
+ for flag in flags:
+ markname = os.path.join(markdir,
+ [x for (x,y) in marktoflagmap if
y==flag][0])
+ if not os.path.exists(markname):
+ os.mkdir(markname)
+ ui.debug('maildir', 'savemessageflags: made '
+ 'nnmaildir mark directory %s' % markname)
+ markname = os.path.join(markname, basename)
+ if not os.path.exists(markname):
+
os.link(os.path.join(self.getfullname(),'.nnmaildir','markfile'),
+ markname)
+ ui.debug('maildir', 'savemessageflags: made '
+ 'nnmaildir mark for %s in %s' % (flag,
markname))
+
def deletemessage(self, uid):
if not uid in self.messagelist:
return
--
Dan Sheridan -- Research Student -- LFCS, Division of Informatics
University of Edinburgh, King's Buildings, Mayfield Road EH9 3JZ
- [PATCH] Offlineimap and Gnus,
Dan Sheridan <=
|
|