From 04f3f6f29768c79040978709666f97e06ee09a2c Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 19 Feb 2020 22:20:21 -0800 Subject: [PATCH] Remove commit=False from all method calls, it's default now. --- etiquette/objects.py | 18 ++++++------- etiquette/photodb.py | 25 +++++++++---------- .../backend/endpoints/album_endpoints.py | 2 +- .../backend/endpoints/photo_endpoints.py | 10 ++++---- .../backend/endpoints/tag_endpoints.py | 2 +- 5 files changed, 28 insertions(+), 29 deletions(-) diff --git a/etiquette/objects.py b/etiquette/objects.py index b9ecedb..cf43254 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -119,7 +119,7 @@ class GroupableMixin: @decorators.transaction def add_children(self, members, *, commit=False): for member in members: - self.add_child(member, commit=False) + self.add_child(member) if commit: self.photodb.commit(message='add multiple to group') @@ -147,7 +147,7 @@ class GroupableMixin: self.photodb._cached_frozen_children = None if delete_children: for child in self.get_children(): - child.delete(delete_children=True, commit=False) + child.delete(delete_children=True) else: self._lift_children() @@ -366,7 +366,7 @@ class Album(ObjectBase, GroupableMixin): photos = self.get_photos() for photo in photos: - photo.add_tag(tag, commit=False) + photo.add_tag(tag) if commit: self.photodb.commit(message='add tag to all') @@ -375,7 +375,7 @@ class Album(ObjectBase, GroupableMixin): @decorators.transaction def delete(self, *, delete_children=False, commit=False): self.photodb.log.debug('Deleting %s', self) - GroupableMixin.delete(self, delete_children=delete_children, commit=False) + GroupableMixin.delete(self, delete_children=delete_children) self.photodb.sql_delete(table='album_associated_directories', pairs={'albumid': self.id}) self.photodb.sql_delete(table='album_photo_rel', pairs={'albumid': self.id}) self.photodb.sql_delete(table='albums', pairs={'id': self.id}) @@ -726,7 +726,7 @@ class Photo(ObjectBase): for parent in tag.walk_parents(): if self.has_tag(parent, check_children=False): self.photodb.log.debug('Preferring new %s over %s', tag, parent) - self.remove_tag(parent, commit=False) + self.remove_tag(parent) self.photodb.log.debug('Applying %s to %s', tag, self) @@ -765,7 +765,7 @@ class Photo(ObjectBase): Take all of the tags owned by other_photo and apply them to this photo. ''' for tag in other_photo.get_tags(): - self.add_tag(tag, commit=False) + self.add_tag(tag) if commit: self.photodb.commit(message='copy tags') @@ -1299,10 +1299,10 @@ class Tag(ObjectBase, GroupableMixin): # For photos that have the old tag and DO already have the new one, # don't worry because the old rels will be deleted when the tag is # deleted. - self.delete(commit=False) + self.delete() # Enjoy your new life as a monk. - mastertag.add_synonym(self.name, commit=False) + mastertag.add_synonym(self.name) if commit: self.photodb.commit(message='convert to synonym') @@ -1311,7 +1311,7 @@ class Tag(ObjectBase, GroupableMixin): def delete(self, *, delete_children=False, commit=False): self.photodb.log.debug('Deleting %s', self) self.photodb._cached_frozen_children = None - GroupableMixin.delete(self, delete_children=delete_children, commit=False) + GroupableMixin.delete(self, delete_children=delete_children) self.photodb.sql_delete(table='photo_tag_rel', pairs={'tagid': self.id}) self.photodb.sql_delete(table='tag_synonyms', pairs={'mastername': self.name}) self.photodb.sql_delete(table='tags', pairs={'id': self.id}) diff --git a/etiquette/photodb.py b/etiquette/photodb.py index 18d03bc..d9c4858 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -110,11 +110,11 @@ class PDBAlbumMixin: album = self.get_cached_instance('album', data) if associated_directory is not None: - album.add_associated_directory(associated_directory, commit=False) + album.add_associated_directory(associated_directory) if photos is not None: photos = [self.get_photo(photo) for photo in photos] - album.add_photos(photos, commit=False) + album.add_photos(photos) if commit: self.commit(message='new album') @@ -269,14 +269,14 @@ class PDBPhotoMixin: photo = self.get_cached_instance('photo', data) if do_metadata: - photo.reload_metadata(commit=False) + photo.reload_metadata() if do_thumbnail: - photo.generate_thumbnail(commit=False) + photo.generate_thumbnail() tags = tags or [] tags = [self.get_tag(name=tag) for tag in tags] for tag in tags: - photo.add_tag(tag, commit=False) + photo.add_tag(tag) if commit: self.commit(message='new photo') @@ -297,7 +297,7 @@ class PDBPhotoMixin: for photo in photos: if photo.real_path.exists: continue - photo.delete(commit=False) + photo.delete() if commit: self.commit(message='purge deleted photos') @@ -317,7 +317,7 @@ class PDBPhotoMixin: continue # This may have been the last child of an otherwise empty parent. to_check.update(album.get_parents()) - album.delete(commit=False) + album.delete() if commit: self.commit(message='purge empty albums') @@ -1176,7 +1176,7 @@ class PDBUtilMixin: try: photo = self.get_photo_by_path(filepath) except exceptions.NoSuchPhoto: - photo = self.new_photo(filepath.absolute_path, commit=False, **new_photo_kwargs) + photo = self.new_photo(filepath.absolute_path, **new_photo_kwargs) if new_photo_ratelimit is not None: new_photo_ratelimit.limit() @@ -1193,7 +1193,6 @@ class PDBUtilMixin: except exceptions.NoSuchAlbum: current_album = self.new_album( associated_directory=current_directory.absolute_path, - commit=False, title=current_directory.basename, ) albums_by_path[current_directory.absolute_path] = current_album @@ -1207,7 +1206,7 @@ class PDBUtilMixin: if not current_album.has_any_parent(): parent = albums_by_path.get(current_directory.parent.absolute_path, None) if parent is not None: - parent.add_child(current_album, commit=False) + parent.add_child(current_album) directory = _normalize_directory(directory) exclude_directories = _normalize_exclude_directories(exclude_directories) @@ -1236,7 +1235,7 @@ class PDBUtilMixin: current_album = create_or_fetch_current_album(albums_by_path, current_directory) orphan_join_parent_album(albums_by_path, current_album, current_directory) - current_album.add_photos(photos, commit=False) + current_album.add_photos(photos) if commit: self.commit(message='digest directory') @@ -1260,7 +1259,7 @@ class PDBUtilMixin: item = self.get_tag(name=name) note = ('existing_tag', item.name) except exceptions.NoSuchTag: - item = self.new_tag(name, author=author, commit=False) + item = self.new_tag(name, author=author) note = ('new_tag', item.name) output_notes.append(note) return item @@ -1278,7 +1277,7 @@ class PDBUtilMixin: tags = [create_or_get(t) for t in tag_parts] for (higher, lower) in zip(tags, tags[1:]): try: - higher.add_child(lower, commit=False) + higher.add_child(lower) note = ('join_group', f'{higher.name}.{lower.name}') output_notes.append(note) except exceptions.GroupExists: diff --git a/frontends/etiquette_flask/backend/endpoints/album_endpoints.py b/frontends/etiquette_flask/backend/endpoints/album_endpoints.py index 8954487..0336bb2 100644 --- a/frontends/etiquette_flask/backend/endpoints/album_endpoints.py +++ b/frontends/etiquette_flask/backend/endpoints/album_endpoints.py @@ -82,7 +82,7 @@ def post_album_remove_child(album_id): def post_album_refresh_directories(album_id): album = common.P_album(album_id) for directory in album.get_associated_directories(): - common.P.digest_directory(directory, commit=False, new_photo_ratelimit=0.1) + common.P.digest_directory(directory, new_photo_ratelimit=0.1) common.P.commit(message='refresh album directories endpoint') return jsonify.make_json_response({}) diff --git a/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py b/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py index 4634bd1..55a418f 100644 --- a/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py +++ b/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py @@ -81,9 +81,9 @@ def post_photo_add_remove_tag_core(photo_ids, tagname, add_or_remove): for photo in photos: if add_or_remove == 'add': - photo.add_tag(tag, commit=False) + photo.add_tag(tag) elif add_or_remove == 'remove': - photo.remove_tag(tag, commit=False) + photo.remove_tag(tag) common.P.commit() response = {'action': add_or_remove, 'tagname': tag.name} @@ -159,10 +159,10 @@ def post_photo_refresh_metadata_core(photo_ids): for photo in photos: common.P.caches['photo'].remove(photo.id) photo = common.P_photo(photo.id, response_type='json') - photo.reload_metadata(commit=False) + photo.reload_metadata() if photo.thumbnail is None: try: - photo.generate_thumbnail(commit=False) + photo.generate_thumbnail() except Exception: traceback.print_exc() @@ -189,7 +189,7 @@ def post_photo_searchhidden_core(photo_ids, searchhidden): photos = list(common.P_photos(photo_ids, response_type='json')) for photo in photos: - photo.set_searchhidden(searchhidden, commit=False) + photo.set_searchhidden(searchhidden) common.P.commit() diff --git a/frontends/etiquette_flask/backend/endpoints/tag_endpoints.py b/frontends/etiquette_flask/backend/endpoints/tag_endpoints.py index 692392c..68cd985 100644 --- a/frontends/etiquette_flask/backend/endpoints/tag_endpoints.py +++ b/frontends/etiquette_flask/backend/endpoints/tag_endpoints.py @@ -37,7 +37,7 @@ def post_tag_edit(specific_tag): tag = common.P_tag(specific_tag) name = request.form.get('name', '').strip() if name: - tag.rename(name, commit=False) + tag.rename(name) description = request.form.get('description', None) tag.edit(description=description)