=== modified file 'launchpadBugs/HTMLOperations.py' --- launchpadBugs/HTMLOperations.py 2007-03-16 15:34:14 +0000 +++ launchpadBugs/HTMLOperations.py 2007-03-17 10:59:45 +0000 @@ -150,17 +150,23 @@ self.bugs = self.bugs.difference(bugexclude) class BugAttachment(object): - def __init__(self, URL, attachments_path, content_types, + def __init__(self, bugnr, URL, attachments_path, content_types, attachments_regex=None): self.url = URL + self.bugnr = bugnr self.contenttype = "" self.text = "" self.filename = "" if "text/plain" not in content_types: content_types.append("text/plain") + self.filename_old = \ + os.path.expanduser(os.path.join(attachments_path, + string.join(self.url.split("/")[-2:], "/"))) self.filename = \ - os.path.expanduser(os.path.join(attachments_path, + os.path.expanduser(os.path.join(attachments_path, bugnr, string.join(self.url.split("/")[-2:], "/"))) + if os.path.exists(self.filename_old): + os.renames(self.filename_old,self.filename) if os.path.exists(self.filename): attachment_file = open(self.filename, "r") self.text = attachment_file.read() @@ -169,7 +175,7 @@ if (not attachments_regex) or \ (attachments_regex and re.search(attachments_regex, self.url.split("/")[-1])): - + req = urllib2.Request(self.url) version = "bughelper/%s (Python-urllib2/%s)" % (utils.find_version_number(),urllib2.__version__) req.add_header('User-agent',version) @@ -240,7 +246,7 @@ if matches: attachmentslist.update(matches) for a in attachmentslist: - self.attachments.add(BugAttachment(a, attachments_path, \ + self.attachments.add(BugAttachment(self.bugnumber.nr, a, attachments_path, \ content_types, \ attachments_regex)) self.text = sanitize_html(self.text)