59
59
@click .option (
60
60
"--check-signatures" ,
61
61
is_flag = True ,
62
- help = "Check signatures for all exported photos in the database to find signatures that don't match." ,
62
+ help = "Check signatures for all exported photos in the database to find signatures that don't match. "
63
+ "See also option --export-dir." ,
63
64
)
64
65
@click .option (
65
66
"--update-signatures" ,
66
67
is_flag = True ,
67
- help = "Update signatures for all exported photos in the database to match on-disk signatures." ,
68
+ help = "Update signatures for all exported photos in the database to match on-disk signatures. "
69
+ "See also option --export-dir." ,
68
70
)
69
71
@click .option (
70
72
"--touch-file" ,
@@ -268,6 +270,7 @@ def exportdb(
268
270
info ,
269
271
last_run ,
270
272
last_export_dir ,
273
+ migrate_photos_library ,
271
274
upgrade ,
272
275
repair ,
273
276
report ,
@@ -323,47 +326,63 @@ def exportdb(
323
326
)
324
327
sys .exit (1 )
325
328
326
- try :
327
- ExportDB (export_db , export_dir , create )
328
- except Exception as e :
329
- rich_echo_error (f"[error]Error: { e } [/error]" )
330
- sys .exit (1 )
329
+ if not dry_run :
330
+ try :
331
+ ExportDB (export_db , export_dir , create )
332
+ except Exception as e :
333
+ rich_echo_error (f"[error]Error: { e } [/error]" )
334
+ sys .exit (1 )
335
+ else :
336
+ rich_echo (f"Created export database [filepath]{ export_db } [/]" )
337
+ sys .exit (0 )
331
338
else :
332
- rich_echo (f"Created export database [filepath]{ export_db } [/]" )
339
+ rich_echo (f"[Dryrun] Created export database [filepath]{ export_db } [/]" )
333
340
sys .exit (0 )
334
341
335
342
if check :
336
- errors = sqlite_check_integrity (export_db )
337
- if not errors :
338
- rich_echo (f"Ok: [filepath]{ export_db } [/]" )
339
- sys .exit (0 )
343
+ if not dry_run :
344
+ errors = sqlite_check_integrity (export_db )
345
+ if not errors :
346
+ rich_echo (f"Ok: [filepath]{ export_db } [/]" )
347
+ sys .exit (0 )
348
+ else :
349
+ rich_echo_error (f"[error]Errors: [filepath]{ export_db } [/][/error]" )
350
+ for error in errors :
351
+ rich_echo_error (error )
352
+ sys .exit (1 )
340
353
else :
341
- rich_echo_error (f"[error]Errors: [filepath]{ export_db } [/][/error]" )
342
- for error in errors :
343
- rich_echo_error (error )
344
- sys .exit (1 )
354
+ rich_echo (f"[Dryrun] Check [filepath]{ export_db } [/]" )
355
+ sys .exit (0 )
345
356
346
357
if repair :
347
- try :
348
- sqlite_repair_db (export_db )
349
- except Exception as e :
350
- rich_echo_error (f"[error]Error: { e } [/error]" )
351
- sys .exit (1 )
358
+ if not dry_run :
359
+ try :
360
+ sqlite_repair_db (export_db )
361
+ except Exception as e :
362
+ rich_echo_error (f"[error]Error: { e } [/error]" )
363
+ sys .exit (1 )
364
+ else :
365
+ rich_echo (f"Ok: [filepath]{ export_db } [/]" )
366
+ sys .exit (0 )
352
367
else :
353
- rich_echo (f"Ok: [filepath]{ export_db } [/]" )
368
+ rich_echo (f"[Dryrun] Repair [filepath]{ export_db } [/]" )
354
369
sys .exit (0 )
355
370
356
371
if vacuum :
357
- try :
358
- start_size = pathlib .Path (export_db ).stat ().st_size
359
- export_db_vacuum (export_db )
360
- except Exception as e :
361
- rich_echo_error (f"[error]Error: { e } [/error]" )
362
- sys .exit (1 )
372
+ if not dry_run :
373
+ try :
374
+ start_size = pathlib .Path (export_db ).stat ().st_size
375
+ export_db_vacuum (export_db )
376
+ except Exception as e :
377
+ rich_echo_error (f"[error]Error: { e } [/error]" )
378
+ sys .exit (1 )
379
+ else :
380
+ rich_echo (
381
+ f"Vacuumed { export_db } ! [num]{ start_size } [/] bytes -> [num]{ pathlib .Path (export_db ).stat ().st_size } [/] bytes"
382
+ )
383
+ sys .exit (0 )
363
384
else :
364
- rich_echo (
365
- f"Vacuumed { export_db } ! [num]{ start_size } [/] bytes -> [num]{ pathlib .Path (export_db ).stat ().st_size } [/] bytes"
366
- )
385
+ rich_echo (f"[Dryrun] Vacuum [filepath]{ export_db } [/]" )
367
386
sys .exit (0 )
368
387
369
388
if update_signatures :
@@ -417,13 +436,17 @@ def exportdb(
417
436
sys .exit (1 )
418
437
419
438
if save_config :
420
- try :
421
- export_db_save_config_to_file (export_db , save_config )
422
- except Exception as e :
423
- rich_echo_error (f"[error]Error: { e } [/error]" )
424
- sys .exit (1 )
439
+ if not dry_run :
440
+ try :
441
+ export_db_save_config_to_file (export_db , save_config )
442
+ except Exception as e :
443
+ rich_echo_error (f"[error]Error: { e } [/error]" )
444
+ sys .exit (1 )
445
+ else :
446
+ rich_echo (f"Saved configuration to [filepath]{ save_config } " )
447
+ sys .exit (0 )
425
448
else :
426
- rich_echo (f"Saved configuration to [filepath]{ save_config } " )
449
+ rich_echo (f"[Dryrun] Saved configuration to [filepath]{ save_config } " )
427
450
sys .exit (0 )
428
451
429
452
if check_signatures :
@@ -561,21 +584,23 @@ def exportdb(
561
584
exportdb = ExportDB (export_db , export_dir )
562
585
for uuid in delete_uuid :
563
586
rich_echo (f"Deleting uuid [uuid]{ uuid } [/] from database." )
564
- count = exportdb .delete_data_for_uuid (uuid )
565
- rich_echo (
566
- f"Deleted [num]{ count } [/] { pluralize (count , 'record' , 'records' )} ."
567
- )
587
+ if not dry_run :
588
+ count = exportdb .delete_data_for_uuid (uuid )
589
+ rich_echo (
590
+ f"Deleted [num]{ count } [/] { pluralize (count , 'record' , 'records' )} ."
591
+ )
568
592
sys .exit (0 )
569
593
570
594
if delete_file :
571
595
# delete information associated with a file from the export database
572
596
exportdb = ExportDB (export_db , export_dir )
573
597
for filepath in delete_file :
574
598
rich_echo (f"Deleting file [filepath]{ filepath } [/] from database." )
575
- count = exportdb .delete_data_for_filepath (filepath )
576
- rich_echo (
577
- f"Deleted [num]{ count } [/] { pluralize (count , 'record' , 'records' )} ."
578
- )
599
+ if not dry_run :
600
+ count = exportdb .delete_data_for_filepath (filepath )
601
+ rich_echo (
602
+ f"Deleted [num]{ count } [/] { pluralize (count , 'record' , 'records' )} ."
603
+ )
579
604
sys .exit (0 )
580
605
581
606
if report :
@@ -599,28 +624,40 @@ def exportdb(
599
624
sys .exit (0 )
600
625
601
626
if upgrade :
602
- exportdb = ExportDB (export_db , export_dir )
603
- if upgraded := exportdb .was_upgraded :
604
- rich_echo (
605
- f"Upgraded export database [filepath]{ export_db } [/] from version [num]{ upgraded [0 ]} [/] to [num]{ upgraded [1 ]} [/]"
606
- )
627
+ if not dry_run :
628
+ exportdb = ExportDB (export_db , export_dir )
629
+ if upgraded := exportdb .was_upgraded :
630
+ rich_echo (
631
+ f"Upgraded export database [filepath]{ export_db } [/] from version [num]{ upgraded [0 ]} [/] to [num]{ upgraded [1 ]} [/]"
632
+ )
633
+ else :
634
+ rich_echo (
635
+ f"Export database [filepath]{ export_db } [/] is already at latest version [num]{ OSXPHOTOS_EXPORTDB_VERSION } [/]"
636
+ )
607
637
else :
638
+ # Does OSXPHOTOS_EXPORTDB_VERSION reflect the actual exportdb file version?
608
639
rich_echo (
609
- f"Export database [filepath] { export_db } [/] is already at latest version [num] { OSXPHOTOS_EXPORTDB_VERSION } [/]"
640
+ f"[Dryrun] Upgrading database [filepath] { export_db } [/]"
610
641
)
611
642
sys .exit (0 )
612
643
613
644
if sql :
614
- exportdb = ExportDB (export_db , export_dir )
615
- try :
616
- c = exportdb ._conn .cursor ()
617
- results = c .execute (sql )
618
- except Exception as e :
619
- rich_echo_error (f"[error]Error: { e } [/error]" )
620
- sys .exit (1 )
645
+ if not dry_run :
646
+ exportdb = ExportDB (export_db , export_dir )
647
+ try :
648
+ c = exportdb ._conn .cursor ()
649
+ results = c .execute (sql )
650
+ except Exception as e :
651
+ rich_echo_error (f"[error]Error: { e } [/error]" )
652
+ sys .exit (1 )
653
+ else :
654
+ for row in results :
655
+ print (row )
656
+ sys .exit (0 )
621
657
else :
622
- for row in results :
623
- print (row )
658
+ rich_echo (
659
+ f"[Dryrun] SQL_STATEMENT: [filepath]{ sql } [/]"
660
+ )
624
661
sys .exit (0 )
625
662
626
663
if migrate_photos_library :
0 commit comments