diff options
author | Ask Solem <askh@modwheel.net> | 2009-03-20 14:37:47 +0100 |
---|---|---|
committer | Ask Solem Hoel <askh@opera.com> | 2009-03-20 14:37:47 +0100 |
commit | a7f67e3cc050a94c2dfe2ce57868a695c7e11bdf (patch) | |
tree | 9d8943ef7a3a601e54a7091c2b6bf4a76bf6e6e0 | |
parent | f5211dc0f3371c52bf0805ac59d4b505a14e4537 (diff) | |
download | chishop-a7f67e3cc050a94c2dfe2ce57868a695c7e11bdf.tar.bz2 chishop-a7f67e3cc050a94c2dfe2ce57868a695c7e11bdf.tar.xz chishop-a7f67e3cc050a94c2dfe2ce57868a695c7e11bdf.zip |
have to delete previous file before creating the new release.
-rw-r--r-- | djangopypi/forms.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/djangopypi/forms.py b/djangopypi/forms.py index 54707e0..ccea903 100644 --- a/djangopypi/forms.py +++ b/djangopypi/forms.py | |||
@@ -62,18 +62,19 @@ class ProjectRegisterForm(forms.Form): | |||
62 | # filename, however with .tar.gz files django does the "wrong" thing | 62 | # filename, however with .tar.gz files django does the "wrong" thing |
63 | # and saves it as project-0.1.2.tar_.gz. So remove it before | 63 | # and saves it as project-0.1.2.tar_.gz. So remove it before |
64 | # django sees anything. | 64 | # django sees anything. |
65 | try: | 65 | if file: |
66 | previous_entry = Release.objects.get(version=version, | 66 | try: |
67 | platform=platform, project=project) | 67 | previous_entry = Release.objects.get(version=version, |
68 | except Release.DoesNotExist: | 68 | platform=platform, project=project) |
69 | pass | 69 | if os.path.exists(previous_entry.distribution.path): |
70 | os.remove(previous_entry.distribution.path) | ||
71 | except Release.DoesNotExist: | ||
72 | pass | ||
73 | |||
70 | 74 | ||
71 | release, created = Release.objects.get_or_create(version=version, | 75 | release, created = Release.objects.get_or_create(version=version, |
72 | platform=platform, | 76 | platform=platform, |
73 | project=project) | 77 | project=project) |
74 | if file: | 78 | if file: |
75 | if not created: | ||
76 | if os.path.exists(release.distribution.path): | ||
77 | os.remove(release.distribution.path) | ||
78 | release.distribution.save(file.name, file, save=True) | 79 | release.distribution.save(file.name, file, save=True) |
79 | release.save() | 80 | release.save() |