Skip to content

Commit

Permalink
Fix for speed slowdown, unnecessary checkpoint, #1083
Browse files Browse the repository at this point in the history
  • Loading branch information
RhetTbull committed Jan 13, 2024
1 parent 97e52c8 commit 83af55e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
3 changes: 0 additions & 3 deletions osxphotos/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,3 @@ class AlbumSortOrder(Enum):
# pass SQLITE_CHECK_SAME_THREAD to sqlite3.connect() to enable multithreaded access on systems that support it
SQLITE_CHECK_SAME_THREAD = not sqlite3.threadsafety == 3
logger.debug(f"{SQLITE_CHECK_SAME_THREAD=}, {sqlite3.threadsafety=}")

# default value for --checkpoint
DEFAULT_CHECKPOINT = 1000
13 changes: 6 additions & 7 deletions osxphotos/cli/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from osxphotos._constants import (
_EXIF_TOOL_URL,
_OSXPHOTOS_NONE_SENTINEL,
DEFAULT_CHECKPOINT,
DEFAULT_EDITED_SUFFIX,
DEFAULT_JPEG_QUALITY,
DEFAULT_ORIGINAL_SUFFIX,
Expand Down Expand Up @@ -757,17 +756,18 @@
"--ramdb",
is_flag=True,
help="Copy export database to memory during export; "
"will improve performance when exporting over a network or slow disk but could result in "
"losing update state information if the program is interrupted or crashes. "
"will improve performance when exporting over a network or slow disk. "
"See also --checkpoint.",
)
@click.option(
"--checkpoint",
metavar="NUMBER_OF_PHOTOS",
help="When used with --ramdb, periodically save the export database "
"back to disk after processing NUMBER_OF_PHOTOS "
"to avoid data loss if export is cancelled or crashes. "
f"Default is {DEFAULT_CHECKPOINT}; to prevent checkpointing of database, use `--checkpoint 0`",
"back to disk after processing NUMBER_OF_PHOTOS. "
"When using --ramdb, the export database will be automatically saved if there is a crash or interrupt "
"thus you do not generally need to specify --checkpoint and doing so may slow down the export "
"if your export database is large. "
"This is an advanced feature for those who need to fine-tune the behavior of osxphotos.",
type=click.IntRange(min=0),
)
@click.option(
Expand Down Expand Up @@ -1630,7 +1630,6 @@ def export_cli(
DEFAULT_PREVIEW_SUFFIX if preview_suffix is None else preview_suffix
)
retry = retry or 0
checkpoint = DEFAULT_CHECKPOINT if checkpoint is None else checkpoint

dest = str(pathlib.Path(dest).resolve())

Expand Down

0 comments on commit 83af55e

Please sign in to comment.