MCPcopy
hub / github.com/mandarons/icloud-docker / _should_send_sync_summary

Function _should_send_sync_summary

src/notify.py:540–580  ·  view source on GitHub ↗

Determine if sync summary notification should be sent. Args: config: Configuration dictionary summary: SyncSummary object Returns: True if notification should be sent, False otherwise

(config, summary)

Source from the content-addressed store, hash-verified

538
539
540def _should_send_sync_summary(config, summary) -> bool:
541 """
542 Determine if sync summary notification should be sent.
543
544 Args:
545 config: Configuration dictionary
546 summary: SyncSummary object
547
548 Returns:
549 True if notification should be sent, False otherwise
550 """
551 # Check if sync summary is enabled
552 if not config_parser.get_sync_summary_enabled(config=config):
553 return False
554
555 # Check if there was any activity
556 if not summary.has_activity():
557 return False
558
559 # Check error/success preferences
560 has_errors = summary.has_errors()
561 on_error = config_parser.get_sync_summary_on_error(config=config)
562 on_success = config_parser.get_sync_summary_on_success(config=config)
563
564 if has_errors and not on_error:
565 return False
566 if not has_errors and not on_success:
567 return False
568
569 # Check minimum downloads threshold
570 min_downloads = config_parser.get_sync_summary_min_downloads(config=config)
571 total_downloads = 0
572 if summary.drive_stats:
573 total_downloads += summary.drive_stats.files_downloaded
574 if summary.photo_stats:
575 total_downloads += summary.photo_stats.photos_downloaded
576
577 if total_downloads < min_downloads:
578 return False
579
580 return True
581
582
583def send_sync_summary(config, summary, dry_run=False):

Calls 2

has_activityMethod · 0.45
has_errorsMethod · 0.45