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.
master
voussoir 2020-09-28 14:18:10 -07:00
parent 585882028d
commit 949e6f68fe
2 changed files with 3 additions and 12 deletions

View File

@ -1059,23 +1059,19 @@ 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.assert_no_such_photo_by_path(filepath=new_filepath)
self.photodb.log.debug('Relocating %s to "%s"', self, new_filepath.absolute_path)
data = {

View File

@ -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,8 +473,7 @@ 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)
self.assert_no_such_photo_by_path(filepath=filepath)
author_id = self.get_user_id_or_none(author)