From: schlatterbeck Date: Sun, 29 May 2011 18:25:49 +0000 (+0000) Subject: Fix file-unlink bug in mailgw (Ralfs oversight when refactoring the mail X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4b134bc0ffdd142b88c9cff1fbf62625d37056a3;p=roundup.git Fix file-unlink bug in mailgw (Ralfs oversight when refactoring the mail gateway code) -- if a message is sent that contains no attachments, all previous files of the issue are unlinked, thanks to Rafal Bisingier for reporting and proposing a fix. I've now added a regression test that catches this issue. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4609 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/CHANGES.txt b/CHANGES.txt index 12d17c4..72a1765 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,13 +2,21 @@ This file contains the changes to the Roundup system over time. The entries are given with the most recent entry first. If no other name is given, Richard Jones did the change. -2011-XX-XX 1.X.XX (rXXXX) +2011-05-29 1.4.18 (rXXXX) Features: - Norwegian Bokmal translation by Christian Aastorp - Allow to specify additional cc and bcc emails (not roundup users) for - nosymessage used by the nosyreaction reactor. + nosymessage used by the nosyreaction reactor. (Ralf) + +Fixed: + +- Fix file-unlink bug in mailgw (Ralfs oversight when refactoring the mail + gateway code) -- if a message is sent that contains no attachments, + all previous files of the issue are unlinked, thanks to Rafal + Bisingier for reporting and proposing a fix. + I've now added a regression test that catches this issue. 2011-05-13 1.4.17 (r4605) diff --git a/doc/acknowledgements.txt b/doc/acknowledgements.txt index 49090a8..2a3542f 100644 --- a/doc/acknowledgements.txt +++ b/doc/acknowledgements.txt @@ -14,6 +14,7 @@ Anthony Baxter, Marlon van den Berg, Bo Berglund, Stéphane Bidoul, +Rafal Bisingier, Cameron Blackwood, Jeff Blaine, Duncan Booth, diff --git a/roundup/mailgw.py b/roundup/mailgw.py index 1664484..23373ed 100644 --- a/roundup/mailgw.py +++ b/roundup/mailgw.py @@ -1058,7 +1058,7 @@ encrypted.""") fileprop.extend(files) files = fileprop - self.props['files'] = files + self.props['files'] = files def create_msg(self): ''' Create msg containing all the relevant information from the message @@ -1093,7 +1093,8 @@ not find a text/plain part to use. try: message_id = self.db.msg.create(author=self.author, recipients=self.recipients, date=date.Date('.'), - summary=summary, content=content, files=self.props['files'], + summary=summary, content=content, + files=self.props.get('files',[]), messageid=messageid, inreplyto=inreplyto, **msg_props) except exceptions.Reject, error: raise MailUsageError, _(""" diff --git a/test/test_mailgw.py b/test/test_mailgw.py index 69c5e07..c85dff0 100644 --- a/test/test_mailgw.py +++ b/test/test_mailgw.py @@ -625,6 +625,36 @@ some text in inner email self.assertEqual(f.content, content [n]) self.assertEqual(msg.content, 'test attachment second text/plain') + def testMultipartKeepFiles(self): + self.doNewIssue() + self._handle_mail(self.multipart_msg) + messages = self.db.issue.get('1', 'messages') + messages.sort() + msg = self.db.msg.getnode (messages[-1]) + assert(len(msg.files) == 5) + issue = self.db.issue.getnode ('1') + assert(len(issue.files) == 5) + names = {0 : 'first.dvi', 4 : 'second.dvi'} + content = {3 : 'test attachment third text/plain\n', + 4 : 'Just a test\n'} + for n, id in enumerate (msg.files): + f = self.db.file.getnode (id) + self.assertEqual(f.name, names.get (n, 'unnamed')) + if n in content : + self.assertEqual(f.content, content [n]) + self.assertEqual(msg.content, 'test attachment second text/plain') + self._handle_mail('''From: mary +To: issue_tracker@your.tracker.email.domain.example +Message-Id: +In-Reply-To: +Subject: [issue1] Testing... + +This ist a message without attachment +''') + issue = self.db.issue.getnode ('1') + assert(len(issue.files) == 5) + self.assertEqual(issue.files, ['1', '2', '3', '4', '5']) + def testMultipartDropAlternatives(self): self.doNewIssue() self.db.config.MAILGW_IGNORE_ALTERNATIVES = True