feat(shell-sync): sync_all() part 2/3

This commit is contained in:
hoelee committed 2026-07-01 09:00:00 +08:00
1 parent 15d09ccb2e
commit dd71bc0e81
1 file changed
+24
+24
View File
@@ -299,3 +299,27 @@ sync_all() {
local successes=""
local failed_accounts=""
log "=== Sync cycle start ==="
for ((i = 1; i <= NUM_ACCOUNTS; i++)); do
if sync_account "$i"; then
if [ "$SYNC_ACCOUNT_RESULT" = "success" ]; then
configured=$((configured + 1))
successes="${successes}${successes:+, }${i}"
if [ "$NOTIFY_MODE" = "account_success" ]; then
send_notification "IMAP sync succeeded for account $i" "Account $i completed successfully at $(date '+%Y-%m-%d %H:%M:%S')." || notification_failures=1
fi
fi
else
configured=$((configured + 1))
failures=$((failures + 1))
failed_accounts="${failed_accounts}${failed_accounts:+, }${i}"
fi
done
if [ "$NOTIFY_MODE" = "batch_success" ] && [ "$configured" -gt 0 ] && [ "$failures" -eq 0 ]; then
send_notification "IMAP sync batch succeeded" "All configured accounts completed successfully at $(date '+%Y-%m-%d %H:%M:%S'): $successes." || notification_failures=1
fi
if [ "$NOTIFY_MODE" = "failure" ] && [ "$failures" -gt 0 ]; then
send_notification "IMAP sync batch failed" "Sync failed for account(s) $failed_accounts at $(date '+%Y-%m-%d %H:%M:%S'). Check ${LOG_DIR}/accountN.log for details." || notification_failures=1
fi