Working on export edited bug for issue #78
This commit is contained in:
@@ -1356,7 +1356,14 @@ def export_photo(
|
||||
click.echo(f"Skipping missing edited photo for {filename}")
|
||||
else:
|
||||
edited_name = pathlib.Path(filename)
|
||||
edited_name = f"{edited_name.stem}_edited{edited_name.suffix}"
|
||||
# check for correct edited suffix
|
||||
if photo.path_edited is not None:
|
||||
edited_suffix = pathlib.Path(photo.path_edited).suffix
|
||||
else:
|
||||
# use filename suffix which might be wrong,
|
||||
# will be corrected by use_photos_export
|
||||
edited_suffix = pathlib.Path(photo.filename).suffix
|
||||
edited_name = f"{edited_name.stem}_edited{edited_suffix}"
|
||||
if verbose:
|
||||
click.echo(f"Exporting edited version of {filename} as {edited_name}")
|
||||
photo.export(
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
""" version info """
|
||||
|
||||
__version__ = "0.22.19"
|
||||
__version__ = "0.22.21"
|
||||
|
||||
@@ -539,7 +539,7 @@ class PhotoInfo:
|
||||
raise FileNotFoundError("Invalid path passed to export")
|
||||
|
||||
if filename and len(filename) == 1:
|
||||
# second arg is filename of picture
|
||||
# if filename passed, use it, but verify extension
|
||||
filename = filename[0]
|
||||
else:
|
||||
# no filename provided so use the default
|
||||
@@ -566,6 +566,20 @@ class PhotoInfo:
|
||||
logging.debug(f"dest ={dest}.filename={filename}")
|
||||
dest = dest / filename
|
||||
|
||||
# check extension of destination
|
||||
if edited and self.path_edited is not None:
|
||||
actual_suffix = pathlib.Path(self.path_edited).suffix
|
||||
elif edited:
|
||||
logging.warning("Invalid suffix check for missing edited file")
|
||||
actual_suffix = ""
|
||||
else:
|
||||
actual_suffix = pathlib.Path(self.filename).suffix
|
||||
|
||||
if dest.suffix != actual_suffix:
|
||||
logging.warning(
|
||||
f"Invalid destination suffix: {dest.suffix}, should be {actual_suffix}"
|
||||
)
|
||||
|
||||
# check to see if file exists and if so, add (1), (2), etc until we find one that works
|
||||
# Photos checks the stem and adds (1), (2), etc which avoids collision with sidecars
|
||||
# e.g. exporting sidecar for file1.png and file1.jpeg
|
||||
|
||||
Reference in New Issue
Block a user