Fixed download-missing to only download when actually missing
This commit is contained in:
@@ -1330,6 +1330,11 @@ def export_photo(
|
|||||||
if "xmp" in sidecar:
|
if "xmp" in sidecar:
|
||||||
sidecar_xmp = True
|
sidecar_xmp = True
|
||||||
|
|
||||||
|
# if download_missing and the photo is missing or path doesn't exist,
|
||||||
|
# try to download with Photos
|
||||||
|
use_photos_export = download_missing and (
|
||||||
|
photo.ismissing or not os.path.exists(photo.path)
|
||||||
|
)
|
||||||
photo_path = photo.export(
|
photo_path = photo.export(
|
||||||
dest,
|
dest,
|
||||||
filename,
|
filename,
|
||||||
@@ -1337,14 +1342,19 @@ def export_photo(
|
|||||||
sidecar_xmp=sidecar_xmp,
|
sidecar_xmp=sidecar_xmp,
|
||||||
live_photo=export_live,
|
live_photo=export_live,
|
||||||
overwrite=overwrite,
|
overwrite=overwrite,
|
||||||
use_photos_export=download_missing,
|
use_photos_export=use_photos_export,
|
||||||
exiftool=exiftool,
|
exiftool=exiftool,
|
||||||
)
|
)
|
||||||
|
|
||||||
# if export-edited, also export the edited version
|
# if export-edited, also export the edited version
|
||||||
# verify the photo has adjustments and valid path to avoid raising an exception
|
# verify the photo has adjustments and valid path to avoid raising an exception
|
||||||
if export_edited and photo.hasadjustments:
|
if export_edited and photo.hasadjustments:
|
||||||
if download_missing or photo.path_edited is not None:
|
# if download_missing and the photo is missing or path doesn't exist,
|
||||||
|
# try to download with Photos
|
||||||
|
use_photos_export = download_missing and photo.path_edited is None
|
||||||
|
if not download_missing and photo.path_edited is None:
|
||||||
|
click.echo(f"Skipping missing edited photo for {filename}")
|
||||||
|
else:
|
||||||
edited_name = pathlib.Path(filename)
|
edited_name = pathlib.Path(filename)
|
||||||
edited_name = f"{edited_name.stem}_edited{edited_name.suffix}"
|
edited_name = f"{edited_name.stem}_edited{edited_name.suffix}"
|
||||||
if verbose:
|
if verbose:
|
||||||
@@ -1356,11 +1366,9 @@ def export_photo(
|
|||||||
sidecar_xmp=sidecar_xmp,
|
sidecar_xmp=sidecar_xmp,
|
||||||
overwrite=overwrite,
|
overwrite=overwrite,
|
||||||
edited=True,
|
edited=True,
|
||||||
use_photos_export=download_missing,
|
use_photos_export=use_photos_export,
|
||||||
exiftool=exiftool,
|
exiftool=exiftool,
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
click.echo(f"Skipping missing edited photo for {filename}")
|
|
||||||
|
|
||||||
return photo_path
|
return photo_path
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
""" version info """
|
""" version info """
|
||||||
|
|
||||||
__version__ = "0.22.17"
|
__version__ = "0.22.19"
|
||||||
|
|||||||
@@ -524,6 +524,8 @@ class PhotoInfo:
|
|||||||
# list of all files exported during this call to export
|
# list of all files exported during this call to export
|
||||||
exported_files = []
|
exported_files = []
|
||||||
|
|
||||||
|
logging.debug(f"dest ={dest}.filename={filename}")
|
||||||
|
|
||||||
# check arguments and get destination path and filename (if provided)
|
# check arguments and get destination path and filename (if provided)
|
||||||
if filename and len(filename) > 2:
|
if filename and len(filename) > 2:
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
@@ -561,6 +563,7 @@ class PhotoInfo:
|
|||||||
# check destination path
|
# check destination path
|
||||||
dest = pathlib.Path(dest)
|
dest = pathlib.Path(dest)
|
||||||
filename = pathlib.Path(filename)
|
filename = pathlib.Path(filename)
|
||||||
|
logging.debug(f"dest ={dest}.filename={filename}")
|
||||||
dest = dest / filename
|
dest = dest / filename
|
||||||
|
|
||||||
# check to see if file exists and if so, add (1), (2), etc until we find one that works
|
# check to see if file exists and if so, add (1), (2), etc until we find one that works
|
||||||
|
|||||||
Reference in New Issue
Block a user