From 89d9c1d893c2ba9969d24f12db051e50270575d2 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Tue, 1 Aug 2017 18:13:54 -0700 Subject: [PATCH] Move the new photo creation out of the exception handler. I don't like the "during the handling of the above exception" because it's misleading as to the source of the problem. --- etiquette/photodb.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/etiquette/photodb.py b/etiquette/photodb.py index 7054599..0f11b61 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -1226,7 +1226,13 @@ class PhotoDB(PDBAlbumMixin, PDBBookmarkMixin, PDBPhotoMixin, PDBTagMixin, PDBUs try: photo = self.get_photo_by_path(filepath) except exceptions.NoSuchPhoto: + makenew = True + else: + makenew = False + + if makenew: photo = self.new_photo(filepath.absolute_path, commit=False, **new_photo_kwargs) + new_photos.append(photo) if not make_albums: