diff --git a/r2/r2/controllers/api.py b/r2/r2/controllers/api.py index 315403e7b..e2ddebe95 100644 --- a/r2/r2/controllers/api.py +++ b/r2/r2/controllers/api.py @@ -1196,9 +1196,7 @@ class ApiController(RedditController): errors['BAD_CSS_NAME'] = _("bad image name") if c.site.images and add_image_to_sr: - if c.site.images.has_key(name): - errors['IMAGE_ERROR'] = _("An image with that name already exists") - elif c.site.get_num_images() >= g.max_sr_images: + if c.site.get_num_images() >= g.max_sr_images: errors['IMAGE_ERROR'] = _("too many images (you only get %d)") % g.max_sr_images if any(errors.values()): diff --git a/r2/r2/models/subreddit.py b/r2/r2/models/subreddit.py index caec5ea1b..d2811a6ce 100644 --- a/r2/r2/models/subreddit.py +++ b/r2/r2/models/subreddit.py @@ -43,7 +43,6 @@ import os.path import random class SubredditExists(Exception): pass -class ImageExists(Exception): pass class Subreddit(Thing, Printable): # Note: As of 2010/03/18, nothing actually overrides the static_path @@ -582,15 +581,12 @@ class Subreddit(Thing, Printable): if max_num is not None and self.get_num_images() >= max_num: raise ValueError, "too many images" - if not self.images.has_key(name): - # copy and blank out the images list to flag as _dirty - l = self.images - self.images = None - # update the dictionary and rewrite to images attr - l[name] = url - self.images = l - else: - raise ImageExists, "image already exists" + # copy and blank out the images list to flag as _dirty + l = self.images + self.images = None + # update the dictionary and rewrite to images attr + l[name] = url + self.images = l def del_image(self, name): """