Working on export edited bug for issue #78

This commit is contained in:
Rhet Turnbull
2020-03-14 20:07:05 -07:00
parent dd20b8d8ac
commit 8542e1a97f
109 changed files with 757 additions and 21 deletions

View File

@@ -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(

View File

@@ -1,3 +1,3 @@
""" version info """
__version__ = "0.22.19"
__version__ = "0.22.21"

View File

@@ -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