Skip to content

Commit 77f911b

Browse files
author
Ralf Schlatterbeck
committed
Yet another fix to the mail gateway...
...messages got *all* files of an issue, not just the new ones. Thanks to Rafal Bisingier for reporting and proposing a fix. The regression test was updated. Fix version numbers in upgrade documentation, the file-unlink defect was in 1.4.17 not 1.4.16. Thanks to Rafal Bisingier.
1 parent befdf38 commit 77f911b

File tree

4 files changed

+61
-16
lines changed

4 files changed

+61
-16
lines changed

CHANGES.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,22 @@ This file contains the changes to the Roundup system over time. The entries
22
are given with the most recent entry first. If no other name is given,
33
Richard Jones did the change.
44

5+
2011-XX-XX 1.4.19 (r46XX)
6+
7+
Fixed:
8+
9+
- Yet another fix to the mail gateway, messages got *all* files of
10+
an issue, not just the new ones. Thanks to Rafal Bisingier for
11+
reporting and proposing a fix. The regression test was updated.
12+
(Ralf)
13+
- Fix version numbers in upgrade documentation, the file-unlink defect
14+
was in 1.4.17 not 1.4.16. Thanks to Rafal Bisingier.
15+
516
2011-05-29 1.4.18 (r4610)
617

718
Features:
819

9-
- Norwegian Bokmal translation by Christian Aastorp (Ralf)
20+
- Norwegian Bokmal translation by Christian Aastorp
1021
- Allow to specify additional cc and bcc emails (not roundup users) for
1122
nosymessage used by the nosyreaction reactor. (Ralf)
1223

doc/upgrading.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ steps.
1313

1414
.. contents::
1515

16-
Migrating from 1.4.16 to 1.4.17
16+
Migrating from 1.4.17 to 1.4.18
1717
===============================
1818

19-
There was a bug in 1.4.16 where files were unlinked from issues if a
19+
There was a bug in 1.4.17 where files were unlinked from issues if a
2020
mail without attachment was received via the mail interface. The
2121
following script will list likely issues being affected by the bug.
22-
The date in the script is the date of the 1.4.16 release. If you have
23-
installed 1.4.16 later than this date, you can change the date
22+
The date in the script is the date of the 1.4.17 release. If you have
23+
installed 1.4.17 later than this date, you can change the date
2424
appropriately to your installation date. Run the script in the directory
2525
of your tracker.
2626

roundup/mailgw.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ def __init__(self, mailgw, message):
549549
self.nodeid = None
550550
self.author = None
551551
self.recipients = None
552+
self.msg_props = {}
552553
self.props = None
553554
self.content = None
554555
self.attachments = None
@@ -1052,6 +1053,7 @@ def create_files(self):
10521053
'You are not permitted to add files to %(classname)s.'
10531054
) % self.__dict__
10541055

1056+
self.msg_props['files'] = files
10551057
if self.nodeid:
10561058
# extend the existing files list
10571059
fileprop = self.cl.get(self.nodeid, 'files')
@@ -1066,6 +1068,7 @@ def create_msg(self):
10661068
if not self.properties.has_key('messages'):
10671069
return
10681070
msg_props = self.mailgw.get_class_arguments('msg')
1071+
self.msg_props.update (msg_props)
10691072

10701073
# Get the message ids
10711074
inreplyto = self.message.getheader('in-reply-to') or ''
@@ -1094,8 +1097,7 @@ def create_msg(self):
10941097
message_id = self.db.msg.create(author=self.author,
10951098
recipients=self.recipients, date=date.Date('.'),
10961099
summary=summary, content=content,
1097-
files=self.props.get('files',[]),
1098-
messageid=messageid, inreplyto=inreplyto, **msg_props)
1100+
messageid=messageid, inreplyto=inreplyto, **self.msg_props)
10991101
except exceptions.Reject, error:
11001102
raise MailUsageError, _("""
11011103
Mail message was rejected by a detector.

test/test_mailgw.py

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -625,15 +625,47 @@ def testMultipartKeepAlternatives(self):
625625
self.assertEqual(f.content, content [n])
626626
self.assertEqual(msg.content, 'test attachment second text/plain')
627627

628+
def testMultipartSeveralAttachmentMessages(self):
629+
self.doNewIssue()
630+
self._handle_mail(self.multipart_msg)
631+
messages = self.db.issue.get('1', 'messages')
632+
messages.sort()
633+
self.assertEqual(messages[-1], '2')
634+
msg = self.db.msg.getnode (messages[-1])
635+
self.assertEqual(len(msg.files), 5)
636+
issue = self.db.issue.getnode ('1')
637+
self.assertEqual(len(issue.files), 5)
638+
names = {0 : 'first.dvi', 4 : 'second.dvi'}
639+
content = {3 : 'test attachment third text/plain\n',
640+
4 : 'Just a test\n'}
641+
for n, id in enumerate (msg.files):
642+
f = self.db.file.getnode (id)
643+
self.assertEqual(f.name, names.get (n, 'unnamed'))
644+
if n in content :
645+
self.assertEqual(f.content, content [n])
646+
self.assertEqual(msg.content, 'test attachment second text/plain')
647+
self.assertEqual(msg.files, ['1', '2', '3', '4', '5'])
648+
self.assertEqual(issue.files, ['1', '2', '3', '4', '5'])
649+
650+
self._handle_mail(self.multipart_msg)
651+
issue = self.db.issue.getnode ('1')
652+
self.assertEqual(len(issue.files), 10)
653+
messages = self.db.issue.get('1', 'messages')
654+
messages.sort()
655+
self.assertEqual(messages[-1], '3')
656+
msg = self.db.msg.getnode (messages[-1])
657+
self.assertEqual(issue.files, [str(i+1) for i in range(10)])
658+
self.assertEqual(msg.files, ['6', '7', '8', '9', '10'])
659+
628660
def testMultipartKeepFiles(self):
629661
self.doNewIssue()
630662
self._handle_mail(self.multipart_msg)
631663
messages = self.db.issue.get('1', 'messages')
632664
messages.sort()
633665
msg = self.db.msg.getnode (messages[-1])
634-
assert(len(msg.files) == 5)
666+
self.assertEqual(len(msg.files), 5)
635667
issue = self.db.issue.getnode ('1')
636-
assert(len(issue.files) == 5)
668+
self.assertEqual(len(issue.files), 5)
637669
names = {0 : 'first.dvi', 4 : 'second.dvi'}
638670
content = {3 : 'test attachment third text/plain\n',
639671
4 : 'Just a test\n'}
@@ -652,7 +684,7 @@ def testMultipartKeepFiles(self):
652684
This ist a message without attachment
653685
''')
654686
issue = self.db.issue.getnode ('1')
655-
assert(len(issue.files) == 5)
687+
self.assertEqual(len(issue.files), 5)
656688
self.assertEqual(issue.files, ['1', '2', '3', '4', '5'])
657689

658690
def testMultipartDropAlternatives(self):
@@ -662,7 +694,7 @@ def testMultipartDropAlternatives(self):
662694
messages = self.db.issue.get('1', 'messages')
663695
messages.sort()
664696
msg = self.db.msg.getnode (messages[-1])
665-
assert(len(msg.files) == 2)
697+
self.assertEqual(len(msg.files), 2)
666698
names = {1 : 'second.dvi'}
667699
content = {0 : 'test attachment third text/plain\n',
668700
1 : 'Just a test\n'}
@@ -681,7 +713,7 @@ def testMultipartCharsetUTF8NoAttach(self):
681713
messages = self.db.issue.get('1', 'messages')
682714
messages.sort()
683715
msg = self.db.msg.getnode (messages[-1])
684-
assert(len(msg.files) == 1)
716+
self.assertEqual(len(msg.files), 1)
685717
name = 'unnamed'
686718
content = '<html>' + c + '</html>\n'
687719
for n, id in enumerate (msg.files):
@@ -732,7 +764,7 @@ def testMultipartCharsetLatin1NoAttach(self):
732764
messages = self.db.issue.get('1', 'messages')
733765
messages.sort()
734766
msg = self.db.msg.getnode (messages[-1])
735-
assert(len(msg.files) == 1)
767+
self.assertEqual(len(msg.files), 1)
736768
name = 'unnamed'
737769
content = '<html>' + c + '</html>\n'
738770
for n, id in enumerate (msg.files):
@@ -781,7 +813,7 @@ def testMultipartCharsetUTF8AttachFile(self):
781813
messages = self.db.issue.get('1', 'messages')
782814
messages.sort()
783815
msg = self.db.msg.getnode (messages[-1])
784-
assert(len(msg.files) == 1)
816+
self.assertEqual(len(msg.files), 1)
785817
name = 'unnamed'
786818
content = '<html>' + c + '</html>\n'
787819
for n, id in enumerate (msg.files):
@@ -845,7 +877,7 @@ def testMultipartCharsetLatin1AttachFile(self):
845877
messages = self.db.issue.get('1', 'messages')
846878
messages.sort()
847879
msg = self.db.msg.getnode (messages[-1])
848-
assert(len(msg.files) == 1)
880+
self.assertEqual(len(msg.files), 1)
849881
name = 'unnamed'
850882
content = '<html>' + c + '</html>\n'
851883
for n, id in enumerate (msg.files):
@@ -907,7 +939,7 @@ def testMultipartRFC822(self):
907939
messages = self.db.issue.get('1', 'messages')
908940
messages.sort()
909941
msg = self.db.msg.getnode (messages[-1])
910-
assert(len(msg.files) == 1)
942+
self.assertEqual(len(msg.files), 1)
911943
name = "Fwd: Original email subject.eml"
912944
for n, id in enumerate (msg.files):
913945
f = self.db.file.getnode (id)

0 commit comments

Comments
 (0)