Move _uncache_sums call out of _add_photo, into callers.

This commit is contained in:
voussoir 2018-05-01 17:48:56 -07:00
parent fa97512586
commit 698981dd29

View file

@ -330,22 +330,17 @@ class Album(ObjectBase, GroupableMixin):
def _add_photo(self, photo): def _add_photo(self, photo):
self.photodb.log.debug('Adding photo %s to %s', photo, self) self.photodb.log.debug('Adding photo %s to %s', photo, self)
data = { data = {'albumid': self.id, 'photoid': photo.id}
'albumid': self.id,
'photoid': photo.id,
}
self.photodb.sql_insert(table='album_photo_rel', data=data) self.photodb.sql_insert(table='album_photo_rel', data=data)
self._uncache_sums()
@decorators.required_feature('album.edit') @decorators.required_feature('album.edit')
@decorators.transaction @decorators.transaction
def add_photo(self, photo, *, commit=True): def add_photo(self, photo, *, commit=True):
if self.photodb != photo.photodb:
raise ValueError('Not the same PhotoDB')
if self.has_photo(photo): if self.has_photo(photo):
return return
self._add_photo(photo) self._add_photo(photo)
self._uncache_sums()
if commit: if commit:
self.photodb.log.debug('Committing - add photo to album') self.photodb.log.debug('Committing - add photo to album')
@ -360,6 +355,7 @@ class Album(ObjectBase, GroupableMixin):
for photo in photos: for photo in photos:
self._add_photo(photo) self._add_photo(photo)
self._uncache_sums()
if commit: if commit:
self.photodb.log.debug('Committing - add photos to album') self.photodb.log.debug('Committing - add photos to album')