Remove commit=False from all method calls, it's default now.
This commit is contained in:
parent
3a9d7fc2dc
commit
04f3f6f297
5 changed files with 28 additions and 29 deletions
|
@ -119,7 +119,7 @@ class GroupableMixin:
|
||||||
@decorators.transaction
|
@decorators.transaction
|
||||||
def add_children(self, members, *, commit=False):
|
def add_children(self, members, *, commit=False):
|
||||||
for member in members:
|
for member in members:
|
||||||
self.add_child(member, commit=False)
|
self.add_child(member)
|
||||||
|
|
||||||
if commit:
|
if commit:
|
||||||
self.photodb.commit(message='add multiple to group')
|
self.photodb.commit(message='add multiple to group')
|
||||||
|
@ -147,7 +147,7 @@ class GroupableMixin:
|
||||||
self.photodb._cached_frozen_children = None
|
self.photodb._cached_frozen_children = None
|
||||||
if delete_children:
|
if delete_children:
|
||||||
for child in self.get_children():
|
for child in self.get_children():
|
||||||
child.delete(delete_children=True, commit=False)
|
child.delete(delete_children=True)
|
||||||
else:
|
else:
|
||||||
self._lift_children()
|
self._lift_children()
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ class Album(ObjectBase, GroupableMixin):
|
||||||
photos = self.get_photos()
|
photos = self.get_photos()
|
||||||
|
|
||||||
for photo in photos:
|
for photo in photos:
|
||||||
photo.add_tag(tag, commit=False)
|
photo.add_tag(tag)
|
||||||
|
|
||||||
if commit:
|
if commit:
|
||||||
self.photodb.commit(message='add tag to all')
|
self.photodb.commit(message='add tag to all')
|
||||||
|
@ -375,7 +375,7 @@ class Album(ObjectBase, GroupableMixin):
|
||||||
@decorators.transaction
|
@decorators.transaction
|
||||||
def delete(self, *, delete_children=False, commit=False):
|
def delete(self, *, delete_children=False, commit=False):
|
||||||
self.photodb.log.debug('Deleting %s', self)
|
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_associated_directories', pairs={'albumid': self.id})
|
||||||
self.photodb.sql_delete(table='album_photo_rel', 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})
|
self.photodb.sql_delete(table='albums', pairs={'id': self.id})
|
||||||
|
@ -726,7 +726,7 @@ class Photo(ObjectBase):
|
||||||
for parent in tag.walk_parents():
|
for parent in tag.walk_parents():
|
||||||
if self.has_tag(parent, check_children=False):
|
if self.has_tag(parent, check_children=False):
|
||||||
self.photodb.log.debug('Preferring new %s over %s', tag, parent)
|
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)
|
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.
|
Take all of the tags owned by other_photo and apply them to this photo.
|
||||||
'''
|
'''
|
||||||
for tag in other_photo.get_tags():
|
for tag in other_photo.get_tags():
|
||||||
self.add_tag(tag, commit=False)
|
self.add_tag(tag)
|
||||||
if commit:
|
if commit:
|
||||||
self.photodb.commit(message='copy tags')
|
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,
|
# 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
|
# don't worry because the old rels will be deleted when the tag is
|
||||||
# deleted.
|
# deleted.
|
||||||
self.delete(commit=False)
|
self.delete()
|
||||||
|
|
||||||
# Enjoy your new life as a monk.
|
# Enjoy your new life as a monk.
|
||||||
mastertag.add_synonym(self.name, commit=False)
|
mastertag.add_synonym(self.name)
|
||||||
if commit:
|
if commit:
|
||||||
self.photodb.commit(message='convert to synonym')
|
self.photodb.commit(message='convert to synonym')
|
||||||
|
|
||||||
|
@ -1311,7 +1311,7 @@ class Tag(ObjectBase, GroupableMixin):
|
||||||
def delete(self, *, delete_children=False, commit=False):
|
def delete(self, *, delete_children=False, commit=False):
|
||||||
self.photodb.log.debug('Deleting %s', self)
|
self.photodb.log.debug('Deleting %s', self)
|
||||||
self.photodb._cached_frozen_children = None
|
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='photo_tag_rel', pairs={'tagid': self.id})
|
||||||
self.photodb.sql_delete(table='tag_synonyms', pairs={'mastername': self.name})
|
self.photodb.sql_delete(table='tag_synonyms', pairs={'mastername': self.name})
|
||||||
self.photodb.sql_delete(table='tags', pairs={'id': self.id})
|
self.photodb.sql_delete(table='tags', pairs={'id': self.id})
|
||||||
|
|
|
@ -110,11 +110,11 @@ class PDBAlbumMixin:
|
||||||
album = self.get_cached_instance('album', data)
|
album = self.get_cached_instance('album', data)
|
||||||
|
|
||||||
if associated_directory is not None:
|
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:
|
if photos is not None:
|
||||||
photos = [self.get_photo(photo) for photo in photos]
|
photos = [self.get_photo(photo) for photo in photos]
|
||||||
album.add_photos(photos, commit=False)
|
album.add_photos(photos)
|
||||||
|
|
||||||
if commit:
|
if commit:
|
||||||
self.commit(message='new album')
|
self.commit(message='new album')
|
||||||
|
@ -269,14 +269,14 @@ class PDBPhotoMixin:
|
||||||
photo = self.get_cached_instance('photo', data)
|
photo = self.get_cached_instance('photo', data)
|
||||||
|
|
||||||
if do_metadata:
|
if do_metadata:
|
||||||
photo.reload_metadata(commit=False)
|
photo.reload_metadata()
|
||||||
if do_thumbnail:
|
if do_thumbnail:
|
||||||
photo.generate_thumbnail(commit=False)
|
photo.generate_thumbnail()
|
||||||
|
|
||||||
tags = tags or []
|
tags = tags or []
|
||||||
tags = [self.get_tag(name=tag) for tag in tags]
|
tags = [self.get_tag(name=tag) for tag in tags]
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
photo.add_tag(tag, commit=False)
|
photo.add_tag(tag)
|
||||||
|
|
||||||
if commit:
|
if commit:
|
||||||
self.commit(message='new photo')
|
self.commit(message='new photo')
|
||||||
|
@ -297,7 +297,7 @@ class PDBPhotoMixin:
|
||||||
for photo in photos:
|
for photo in photos:
|
||||||
if photo.real_path.exists:
|
if photo.real_path.exists:
|
||||||
continue
|
continue
|
||||||
photo.delete(commit=False)
|
photo.delete()
|
||||||
|
|
||||||
if commit:
|
if commit:
|
||||||
self.commit(message='purge deleted photos')
|
self.commit(message='purge deleted photos')
|
||||||
|
@ -317,7 +317,7 @@ class PDBPhotoMixin:
|
||||||
continue
|
continue
|
||||||
# This may have been the last child of an otherwise empty parent.
|
# This may have been the last child of an otherwise empty parent.
|
||||||
to_check.update(album.get_parents())
|
to_check.update(album.get_parents())
|
||||||
album.delete(commit=False)
|
album.delete()
|
||||||
|
|
||||||
if commit:
|
if commit:
|
||||||
self.commit(message='purge empty albums')
|
self.commit(message='purge empty albums')
|
||||||
|
@ -1176,7 +1176,7 @@ class PDBUtilMixin:
|
||||||
try:
|
try:
|
||||||
photo = self.get_photo_by_path(filepath)
|
photo = self.get_photo_by_path(filepath)
|
||||||
except exceptions.NoSuchPhoto:
|
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:
|
if new_photo_ratelimit is not None:
|
||||||
new_photo_ratelimit.limit()
|
new_photo_ratelimit.limit()
|
||||||
|
|
||||||
|
@ -1193,7 +1193,6 @@ class PDBUtilMixin:
|
||||||
except exceptions.NoSuchAlbum:
|
except exceptions.NoSuchAlbum:
|
||||||
current_album = self.new_album(
|
current_album = self.new_album(
|
||||||
associated_directory=current_directory.absolute_path,
|
associated_directory=current_directory.absolute_path,
|
||||||
commit=False,
|
|
||||||
title=current_directory.basename,
|
title=current_directory.basename,
|
||||||
)
|
)
|
||||||
albums_by_path[current_directory.absolute_path] = current_album
|
albums_by_path[current_directory.absolute_path] = current_album
|
||||||
|
@ -1207,7 +1206,7 @@ class PDBUtilMixin:
|
||||||
if not current_album.has_any_parent():
|
if not current_album.has_any_parent():
|
||||||
parent = albums_by_path.get(current_directory.parent.absolute_path, None)
|
parent = albums_by_path.get(current_directory.parent.absolute_path, None)
|
||||||
if parent is not None:
|
if parent is not None:
|
||||||
parent.add_child(current_album, commit=False)
|
parent.add_child(current_album)
|
||||||
|
|
||||||
directory = _normalize_directory(directory)
|
directory = _normalize_directory(directory)
|
||||||
exclude_directories = _normalize_exclude_directories(exclude_directories)
|
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)
|
current_album = create_or_fetch_current_album(albums_by_path, current_directory)
|
||||||
orphan_join_parent_album(albums_by_path, current_album, 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:
|
if commit:
|
||||||
self.commit(message='digest directory')
|
self.commit(message='digest directory')
|
||||||
|
@ -1260,7 +1259,7 @@ class PDBUtilMixin:
|
||||||
item = self.get_tag(name=name)
|
item = self.get_tag(name=name)
|
||||||
note = ('existing_tag', item.name)
|
note = ('existing_tag', item.name)
|
||||||
except exceptions.NoSuchTag:
|
except exceptions.NoSuchTag:
|
||||||
item = self.new_tag(name, author=author, commit=False)
|
item = self.new_tag(name, author=author)
|
||||||
note = ('new_tag', item.name)
|
note = ('new_tag', item.name)
|
||||||
output_notes.append(note)
|
output_notes.append(note)
|
||||||
return item
|
return item
|
||||||
|
@ -1278,7 +1277,7 @@ class PDBUtilMixin:
|
||||||
tags = [create_or_get(t) for t in tag_parts]
|
tags = [create_or_get(t) for t in tag_parts]
|
||||||
for (higher, lower) in zip(tags, tags[1:]):
|
for (higher, lower) in zip(tags, tags[1:]):
|
||||||
try:
|
try:
|
||||||
higher.add_child(lower, commit=False)
|
higher.add_child(lower)
|
||||||
note = ('join_group', f'{higher.name}.{lower.name}')
|
note = ('join_group', f'{higher.name}.{lower.name}')
|
||||||
output_notes.append(note)
|
output_notes.append(note)
|
||||||
except exceptions.GroupExists:
|
except exceptions.GroupExists:
|
||||||
|
|
|
@ -82,7 +82,7 @@ def post_album_remove_child(album_id):
|
||||||
def post_album_refresh_directories(album_id):
|
def post_album_refresh_directories(album_id):
|
||||||
album = common.P_album(album_id)
|
album = common.P_album(album_id)
|
||||||
for directory in album.get_associated_directories():
|
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')
|
common.P.commit(message='refresh album directories endpoint')
|
||||||
return jsonify.make_json_response({})
|
return jsonify.make_json_response({})
|
||||||
|
|
||||||
|
|
|
@ -81,9 +81,9 @@ def post_photo_add_remove_tag_core(photo_ids, tagname, add_or_remove):
|
||||||
|
|
||||||
for photo in photos:
|
for photo in photos:
|
||||||
if add_or_remove == 'add':
|
if add_or_remove == 'add':
|
||||||
photo.add_tag(tag, commit=False)
|
photo.add_tag(tag)
|
||||||
elif add_or_remove == 'remove':
|
elif add_or_remove == 'remove':
|
||||||
photo.remove_tag(tag, commit=False)
|
photo.remove_tag(tag)
|
||||||
common.P.commit()
|
common.P.commit()
|
||||||
|
|
||||||
response = {'action': add_or_remove, 'tagname': tag.name}
|
response = {'action': add_or_remove, 'tagname': tag.name}
|
||||||
|
@ -159,10 +159,10 @@ def post_photo_refresh_metadata_core(photo_ids):
|
||||||
for photo in photos:
|
for photo in photos:
|
||||||
common.P.caches['photo'].remove(photo.id)
|
common.P.caches['photo'].remove(photo.id)
|
||||||
photo = common.P_photo(photo.id, response_type='json')
|
photo = common.P_photo(photo.id, response_type='json')
|
||||||
photo.reload_metadata(commit=False)
|
photo.reload_metadata()
|
||||||
if photo.thumbnail is None:
|
if photo.thumbnail is None:
|
||||||
try:
|
try:
|
||||||
photo.generate_thumbnail(commit=False)
|
photo.generate_thumbnail()
|
||||||
except Exception:
|
except Exception:
|
||||||
traceback.print_exc()
|
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'))
|
photos = list(common.P_photos(photo_ids, response_type='json'))
|
||||||
|
|
||||||
for photo in photos:
|
for photo in photos:
|
||||||
photo.set_searchhidden(searchhidden, commit=False)
|
photo.set_searchhidden(searchhidden)
|
||||||
|
|
||||||
common.P.commit()
|
common.P.commit()
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ def post_tag_edit(specific_tag):
|
||||||
tag = common.P_tag(specific_tag)
|
tag = common.P_tag(specific_tag)
|
||||||
name = request.form.get('name', '').strip()
|
name = request.form.get('name', '').strip()
|
||||||
if name:
|
if name:
|
||||||
tag.rename(name, commit=False)
|
tag.rename(name)
|
||||||
|
|
||||||
description = request.form.get('description', None)
|
description = request.form.get('description', None)
|
||||||
tag.edit(description=description)
|
tag.edit(description=description)
|
||||||
|
|
Loading…
Reference in a new issue