Removed file locking, performance improvements (#1032)
This commit is contained in:
parent
93d22c646f
commit
36ce86c4a6
@ -1427,21 +1427,21 @@ def export(
|
|||||||
photo_num = 0
|
photo_num = 0
|
||||||
num_exported = 0
|
num_exported = 0
|
||||||
limit_str = f" (limit = [num]{limit}[/num])" if limit else ""
|
limit_str = f" (limit = [num]{limit}[/num])" if limit else ""
|
||||||
|
# hack to avoid passing all the options to export_photo
|
||||||
|
kwargs = {
|
||||||
|
k: v
|
||||||
|
for k, v in locals().items()
|
||||||
|
if k in inspect.getfullargspec(export_photo).args
|
||||||
|
}
|
||||||
|
kwargs["export_dir"] = dest
|
||||||
|
kwargs["export_preview"] = preview
|
||||||
with rich_progress(console=get_verbose_console(), mock=no_progress) as progress:
|
with rich_progress(console=get_verbose_console(), mock=no_progress) as progress:
|
||||||
task = progress.add_task(
|
task = progress.add_task(
|
||||||
f"Exporting [num]{num_photos}[/] photos{limit_str}", total=num_photos
|
f"Exporting [num]{num_photos}[/] photos{limit_str}", total=num_photos
|
||||||
)
|
)
|
||||||
for p in photos:
|
for p in photos:
|
||||||
photo_num += 1
|
photo_num += 1
|
||||||
# hack to avoid passing all the options to export_photo
|
|
||||||
kwargs = {
|
|
||||||
k: v
|
|
||||||
for k, v in locals().items()
|
|
||||||
if k in inspect.getfullargspec(export_photo).args
|
|
||||||
}
|
|
||||||
kwargs["photo"] = p
|
kwargs["photo"] = p
|
||||||
kwargs["export_dir"] = dest
|
|
||||||
kwargs["export_preview"] = preview
|
|
||||||
export_results = export_photo(**kwargs)
|
export_results = export_photo(**kwargs)
|
||||||
if post_function:
|
if post_function:
|
||||||
for function in post_function:
|
for function in post_function:
|
||||||
|
|||||||
@ -432,7 +432,9 @@ def lock_filename(filepath: Union[str, pathlib.Path]) -> bool:
|
|||||||
Returns:
|
Returns:
|
||||||
filepath if lock file created, False if lock file already exists
|
filepath if lock file created, False if lock file already exists
|
||||||
"""
|
"""
|
||||||
|
return filepath
|
||||||
|
|
||||||
|
# TODO: for future implementation
|
||||||
lockfile = pathlib.Path(f"{filepath}.osxphotos.lock")
|
lockfile = pathlib.Path(f"{filepath}.osxphotos.lock")
|
||||||
if lockfile.exists():
|
if lockfile.exists():
|
||||||
return False
|
return False
|
||||||
@ -447,6 +449,9 @@ def unlock_filename(filepath: Union[str, pathlib.Path]):
|
|||||||
filepath: str or pathlib.Path; full path, including file name
|
filepath: str or pathlib.Path; full path, including file name
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
# TODO: for future implementation
|
||||||
lockfile = pathlib.Path(f"{filepath}.osxphotos.lock")
|
lockfile = pathlib.Path(f"{filepath}.osxphotos.lock")
|
||||||
if lockfile.exists():
|
if lockfile.exists():
|
||||||
lockfile.unlink()
|
lockfile.unlink()
|
||||||
@ -539,6 +544,7 @@ def shortuuid_to_uuid(short_uuid: str) -> str:
|
|||||||
"""Convert shortuuid to uuid"""
|
"""Convert shortuuid to uuid"""
|
||||||
return str(shortuuid.decode(short_uuid)).upper()
|
return str(shortuuid.decode(short_uuid)).upper()
|
||||||
|
|
||||||
|
|
||||||
def under_test() -> bool:
|
def under_test() -> bool:
|
||||||
"""Return True if running under pytest"""
|
"""Return True if running under pytest"""
|
||||||
return "pytest" in sys.modules
|
return "pytest" in sys.modules
|
||||||
|
|||||||
@ -27,7 +27,6 @@ def test_dd_to_dms():
|
|||||||
|
|
||||||
@pytest.mark.skip(reason="Fails on some machines")
|
@pytest.mark.skip(reason="Fails on some machines")
|
||||||
def test_get_system_library_path():
|
def test_get_system_library_path():
|
||||||
|
|
||||||
_, major, _ = osxphotos.utils._get_os_version()
|
_, major, _ = osxphotos.utils._get_os_version()
|
||||||
if int(major) < 15:
|
if int(major) < 15:
|
||||||
assert osxphotos.utils.get_system_library_path() is None
|
assert osxphotos.utils.get_system_library_path() is None
|
||||||
@ -84,7 +83,6 @@ def test_list_directory():
|
|||||||
|
|
||||||
|
|
||||||
def test_list_directory_invalid():
|
def test_list_directory_invalid():
|
||||||
|
|
||||||
temp_dir = tempfile.TemporaryDirectory(prefix="osxphotos_")
|
temp_dir = tempfile.TemporaryDirectory(prefix="osxphotos_")
|
||||||
files = list_directory(f"{temp_dir.name}/no_such_dir", glob="*.jpg")
|
files = list_directory(f"{temp_dir.name}/no_such_dir", glob="*.jpg")
|
||||||
assert len(files) == 0
|
assert len(files) == 0
|
||||||
@ -151,6 +149,7 @@ def test_increment_filename_with_lock():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skip(reason="Lock files not yet implemented")
|
||||||
def test_increment_filename_with_lock_exists():
|
def test_increment_filename_with_lock_exists():
|
||||||
# test that increment_filename works with lock=True when lock file already exists
|
# test that increment_filename works with lock=True when lock file already exists
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user