Added lock files to export to minimize name collisions (#981)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""export command for osxphotos CLI"""
|
||||
|
||||
import atexit
|
||||
import inspect
|
||||
import os
|
||||
import pathlib
|
||||
@@ -63,8 +64,10 @@ from osxphotos.utils import (
|
||||
get_macos_version,
|
||||
normalize_fs_path,
|
||||
pluralize,
|
||||
under_test,
|
||||
)
|
||||
|
||||
from .cli_commands import logger
|
||||
from .cli_params import (
|
||||
DB_ARGUMENT,
|
||||
DB_OPTION,
|
||||
@@ -1406,6 +1409,20 @@ def export(
|
||||
else None
|
||||
)
|
||||
|
||||
def cleanup_lock_files():
|
||||
"""Cleanup lock files"""
|
||||
if not under_test():
|
||||
verbose("Cleaning up lock files")
|
||||
if dry_run:
|
||||
return
|
||||
for lock_file in pathlib.Path(dest).rglob("*.osxphotos.lock"):
|
||||
try:
|
||||
lock_file.unlink()
|
||||
except Exception as e:
|
||||
logger.debug(f"Error removing lock file {lock_file}: {e}")
|
||||
|
||||
atexit.register(cleanup_lock_files)
|
||||
|
||||
photo_num = 0
|
||||
num_exported = 0
|
||||
limit_str = f" (limit = [num]{limit}[/num])" if limit else ""
|
||||
|
||||
Reference in New Issue
Block a user