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,23 +1059,19 @@ class Photo(ObjectBase):
|
||||||
|
|
||||||
@decorators.required_feature('photo.edit')
|
@decorators.required_feature('photo.edit')
|
||||||
@decorators.transaction
|
@decorators.transaction
|
||||||
def relocate(self, new_filepath, *, allow_duplicates=False):
|
def relocate(self, new_filepath):
|
||||||
'''
|
'''
|
||||||
Point the Photo object to a different filepath.
|
Point the Photo object to a different filepath.
|
||||||
|
|
||||||
DOES NOT MOVE THE FILE, only acknowledges a move that was performed
|
DOES NOT MOVE THE FILE, only acknowledges a move that was performed
|
||||||
outside of the system.
|
outside of the system.
|
||||||
To rename or move the file, use `rename_file`.
|
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)
|
new_filepath = pathclass.Path(new_filepath)
|
||||||
if not new_filepath.is_file:
|
if not new_filepath.is_file:
|
||||||
raise FileNotFoundError(new_filepath.absolute_path)
|
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)
|
self.photodb.log.debug('Relocating %s to "%s"', self, new_filepath.absolute_path)
|
||||||
data = {
|
data = {
|
||||||
|
|
|
@ -456,7 +456,6 @@ class PDBPhotoMixin:
|
||||||
self,
|
self,
|
||||||
filepath,
|
filepath,
|
||||||
*,
|
*,
|
||||||
allow_duplicates=False,
|
|
||||||
author=None,
|
author=None,
|
||||||
do_metadata=True,
|
do_metadata=True,
|
||||||
do_thumbnail=True,
|
do_thumbnail=True,
|
||||||
|
@ -467,9 +466,6 @@ class PDBPhotoMixin:
|
||||||
Given a filepath, determine its attributes and create a new Photo object
|
Given a filepath, determine its attributes and create a new Photo object
|
||||||
in the database. Tags may be applied now or later.
|
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.
|
Returns the Photo object.
|
||||||
'''
|
'''
|
||||||
# These might raise exceptions
|
# These might raise exceptions
|
||||||
|
@ -477,8 +473,7 @@ class PDBPhotoMixin:
|
||||||
if not filepath.is_file:
|
if not filepath.is_file:
|
||||||
raise FileNotFoundError(filepath.absolute_path)
|
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)
|
author_id = self.get_user_id_or_none(author)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue