diff --git a/README.md b/README.md
index 871373a6..4ddc4e0d 100644
--- a/README.md
+++ b/README.md
@@ -1704,7 +1704,7 @@ Substitution Description
{lf} A line feed: '\n', alias for {newline}
{cr} A carriage return: '\r'
{crlf} a carriage return + line feed: '\r\n'
-{osxphotos_version} The osxphotos version, e.g. '0.42.92'
+{osxphotos_version} The osxphotos version, e.g. '0.42.93'
{osxphotos_cmd_line} The full command line used to run osxphotos
The following substitutions may result in multiple values. Thus if specified for
@@ -3575,7 +3575,7 @@ The following template field substitutions are availabe for use the templating s
|{lf}|A line feed: '\n', alias for {newline}|
|{cr}|A carriage return: '\r'|
|{crlf}|a carriage return + line feed: '\r\n'|
-|{osxphotos_version}|The osxphotos version, e.g. '0.42.92'|
+|{osxphotos_version}|The osxphotos version, e.g. '0.42.93'|
|{osxphotos_cmd_line}|The full command line used to run osxphotos|
|{album}|Album(s) photo is contained in|
|{folder_album}|Folder path + album photo is contained in. e.g. 'Folder/Subfolder/Album' or just 'Album' if no enclosing folder|
diff --git a/docs/.buildinfo b/docs/.buildinfo
index fab795c7..626457d3 100644
--- a/docs/.buildinfo
+++ b/docs/.buildinfo
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
-config: 6564e20384a93b761507f9dc75a6a08a
+config: 642fb2b37def3cc1207bd4b6657f9fd0
tags: 645f666f9bcd5a90fca523b33c5a78b7
diff --git a/docs/_modules/index.html b/docs/_modules/index.html
index c77cb3eb..59d076eb 100644
--- a/docs/_modules/index.html
+++ b/docs/_modules/index.html
@@ -5,7 +5,7 @@
- Overview: module code — osxphotos 0.42.92 documentation
+ Overview: module code — osxphotos 0.42.93 documentation
diff --git a/docs/_modules/osxphotos/photoinfo/_photoinfo_export.html b/docs/_modules/osxphotos/photoinfo/_photoinfo_export.html
index e51a10e4..69db1f4d 100644
--- a/docs/_modules/osxphotos/photoinfo/_photoinfo_export.html
+++ b/docs/_modules/osxphotos/photoinfo/_photoinfo_export.html
@@ -5,7 +5,7 @@
- osxphotos.photoinfo._photoinfo_export — osxphotos 0.42.84 documentation
+ osxphotos.photoinfo._photoinfo_export — osxphotos 0.42.93 documentation
@@ -945,7 +945,11 @@
preview_path = pathlib . Path ( self . path_derivatives [ 0 ])
preview_ext = preview_path . suffix
preview_name = dest . parent / f " { dest . stem }{ preview_suffix }{ preview_ext } "
- preview_name = pathlib . Path ( increment_filename ( preview_name ))
+ preview_name = (
+ preview_name
+ if overwrite
+ else pathlib . Path ( increment_filename ( preview_name ))
+ )
if preview_path is not None :
results = self . _export_photo (
preview_path ,
diff --git a/docs/_static/documentation_options.js b/docs/_static/documentation_options.js
index b5a0cee3..1ea2a208 100644
--- a/docs/_static/documentation_options.js
+++ b/docs/_static/documentation_options.js
@@ -1,6 +1,6 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
- VERSION: '0.42.92',
+ VERSION: '0.42.93',
LANGUAGE: 'None',
COLLAPSE_INDEX: false,
BUILDER: 'html',
diff --git a/docs/cli.html b/docs/cli.html
index 5cd2002d..bc0cf61b 100644
--- a/docs/cli.html
+++ b/docs/cli.html
@@ -5,7 +5,7 @@
- osxphotos command line interface (CLI) — osxphotos 0.42.92 documentation
+ osxphotos command line interface (CLI) — osxphotos 0.42.93 documentation
diff --git a/docs/genindex.html b/docs/genindex.html
index c95c90ea..d3dff249 100644
--- a/docs/genindex.html
+++ b/docs/genindex.html
@@ -5,7 +5,7 @@
- Index — osxphotos 0.42.92 documentation
+ Index — osxphotos 0.42.93 documentation
diff --git a/docs/index.html b/docs/index.html
index ff7ff92e..6fee3d5c 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -5,7 +5,7 @@
- Welcome to osxphotos’s documentation! — osxphotos 0.42.92 documentation
+ Welcome to osxphotos’s documentation! — osxphotos 0.42.93 documentation
diff --git a/docs/modules.html b/docs/modules.html
index efb26610..eaa5fff8 100644
--- a/docs/modules.html
+++ b/docs/modules.html
@@ -5,7 +5,7 @@
- osxphotos — osxphotos 0.42.92 documentation
+ osxphotos — osxphotos 0.42.93 documentation
diff --git a/docs/reference.html b/docs/reference.html
index a7b849fa..4099c1ca 100644
--- a/docs/reference.html
+++ b/docs/reference.html
@@ -5,7 +5,7 @@
- osxphotos package — osxphotos 0.42.92 documentation
+ osxphotos package — osxphotos 0.42.93 documentation
diff --git a/docs/search.html b/docs/search.html
index 08c6b08a..af427645 100644
--- a/docs/search.html
+++ b/docs/search.html
@@ -5,7 +5,7 @@
- Search — osxphotos 0.42.92 documentation
+ Search — osxphotos 0.42.93 documentation
diff --git a/osxphotos/_version.py b/osxphotos/_version.py
index cd583424..fef8b01f 100644
--- a/osxphotos/_version.py
+++ b/osxphotos/_version.py
@@ -1,3 +1,3 @@
""" version info """
-__version__ = "0.42.92"
+__version__ = "0.42.93"
diff --git a/osxphotos/photoinfo/_photoinfo_export.py b/osxphotos/photoinfo/_photoinfo_export.py
index bb520603..6b271e92 100644
--- a/osxphotos/photoinfo/_photoinfo_export.py
+++ b/osxphotos/photoinfo/_photoinfo_export.py
@@ -912,7 +912,11 @@ def export2(
preview_path = pathlib.Path(self.path_derivatives[0])
preview_ext = preview_path.suffix
preview_name = dest.parent / f"{dest.stem}{preview_suffix}{preview_ext}"
- preview_name = pathlib.Path(increment_filename(preview_name))
+ preview_name = (
+ preview_name
+ if overwrite
+ else pathlib.Path(increment_filename(preview_name))
+ )
if preview_path is not None:
results = self._export_photo(
preview_path,
diff --git a/tests/test_cli.py b/tests/test_cli.py
index d732a4a6..03554ec4 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -1483,6 +1483,50 @@ def test_export_preview_if_missing():
assert sorted(files) == sorted(expected_files)
+def test_export_preview_overwrite():
+ """test export with --preview and --overwrite (#526)"""
+ import glob
+ import os
+ import os.path
+
+ import osxphotos
+ from osxphotos.cli import export
+
+ runner = CliRunner()
+ cwd = os.getcwd()
+ # pylint: disable=not-context-manager
+ with runner.isolated_filesystem():
+ result = runner.invoke(
+ export,
+ [
+ os.path.join(cwd, CLI_PHOTOS_DB),
+ ".",
+ "-V",
+ "--preview",
+ "--uuid",
+ CLI_EXPORT_UUID,
+ ],
+ )
+ assert result.exit_code == 0
+
+ # export again
+ result = runner.invoke(
+ export,
+ [
+ os.path.join(cwd, CLI_PHOTOS_DB),
+ ".",
+ "-V",
+ "--preview",
+ "--uuid",
+ CLI_EXPORT_UUID,
+ "--overwrite",
+ ],
+ )
+ assert result.exit_code == 0
+ files = glob.glob("*")
+ assert len(files) == 2 # preview + original
+
+
def test_export_as_hardlink():
import glob
import os
@@ -6958,6 +7002,7 @@ def test_query_regex_multiple():
assert len(json_got) == 2
+
def test_query_function():
"""test query --query-function"""
import json