Remove support for two Photos with same path.
I have yet to find a practical need for this, and all it does is cause headaches about the safety of moving / renaming the file.
This commit is contained in:
parent
585882028d
commit
949e6f68fe
2 changed files with 3 additions and 12 deletions
|
@ -1059,22 +1059,18 @@ class Photo(ObjectBase):
|
|||
|
||||
@decorators.required_feature('photo.edit')
|
||||
@decorators.transaction
|
||||
def relocate(self, new_filepath, *, allow_duplicates=False):
|
||||
def relocate(self, new_filepath):
|
||||
'''
|
||||
Point the Photo object to a different filepath.
|
||||
|
||||
DOES NOT MOVE THE FILE, only acknowledges a move that was performed
|
||||
outside of the system.
|
||||
To rename or move the file, use `rename_file`.
|
||||
|
||||
allow_duplicates:
|
||||
Allow even if there is another Photo for that path.
|
||||
'''
|
||||
new_filepath = pathclass.Path(new_filepath)
|
||||
if not new_filepath.is_file:
|
||||
raise FileNotFoundError(new_filepath.absolute_path)
|
||||
|
||||
if not allow_duplicates:
|
||||
self.photodb.assert_no_such_photo_by_path(filepath=new_filepath)
|
||||
|
||||
self.photodb.log.debug('Relocating %s to "%s"', self, new_filepath.absolute_path)
|
||||
|
|
|
@ -456,7 +456,6 @@ class PDBPhotoMixin:
|
|||
self,
|
||||
filepath,
|
||||
*,
|
||||
allow_duplicates=False,
|
||||
author=None,
|
||||
do_metadata=True,
|
||||
do_thumbnail=True,
|
||||
|
@ -467,9 +466,6 @@ class PDBPhotoMixin:
|
|||
Given a filepath, determine its attributes and create a new Photo object
|
||||
in the database. Tags may be applied now or later.
|
||||
|
||||
If `allow_duplicates` is False, we will first check the database for any
|
||||
files with the same path and raise exceptions.PhotoExists if found.
|
||||
|
||||
Returns the Photo object.
|
||||
'''
|
||||
# These might raise exceptions
|
||||
|
@ -477,7 +473,6 @@ class PDBPhotoMixin:
|
|||
if not filepath.is_file:
|
||||
raise FileNotFoundError(filepath.absolute_path)
|
||||
|
||||
if not allow_duplicates:
|
||||
self.assert_no_such_photo_by_path(filepath=filepath)
|
||||
|
||||
author_id = self.get_user_id_or_none(author)
|
||||
|
|
Loading…
Reference in a new issue