Benjamin Renard commited on 2012-04-20 15:32:11
Showing 1 changed files, with 11 additions and 2 deletions.
... | ... |
@@ -5,6 +5,7 @@ import logging |
5 | 5 |
import re |
6 | 6 |
import MantisMail |
7 | 7 |
import base64 |
8 |
+import time |
|
8 | 9 |
|
9 | 10 |
class MantisWS(object): |
10 | 11 |
|
... | ... |
@@ -79,8 +80,16 @@ class MantisWS(object): |
79 | 80 |
logging.error('Problem adding attachment %s to issue %s' % (attachment['filename'],issue_id)) |
80 | 81 |
err=str(e) |
81 | 82 |
if re.search('Duplicate filename',err): |
82 |
- raise MantisWSError('duplicate_attachment_filename','Duplicate attachment filename %s in issue %s' % (attachment['filename'],issue_id)) |
|
83 |
- except: |
|
83 |
+ newname="%s-%s" % (time.time(),attachment['filename']) |
|
84 |
+ logging.info('Duplicate attachment filename %s in issue %s. Rename it to %s and add again.' % (attachment['filename'],issue_id,newname)) |
|
85 |
+ attachment['filename']=newname |
|
86 |
+ try: |
|
87 |
+ self.add_attachment_to_issue(issue_id,attachment) |
|
88 |
+ except Exception, e: |
|
89 |
+ raise MantisWSError('general_attachment','Problem adding attachment %s to issue %s' % (attachment['filename'],issue_id)) |
|
90 |
+ else: |
|
91 |
+ raise MantisWSError('general_attachment','Problem adding attachment %s to issue %s' % (attachment['filename'],issue_id)) |
|
92 |
+ except Exception, e: |
|
84 | 93 |
logging.error('Problem adding attachment %s to issue %s' % (attachment['filename'],issue_id)) |
85 | 94 |
raise MantisWSError('general_attachment','Problem adding attachment %s to issue %s' % (attachment['filename'],issue_id)) |
86 | 95 |
return None |
87 | 96 |