feat(shell-sync): sync_account() part 3/3

This commit is contained in:
hoelee committed 2026-06-29 09:00:00 +08:00
1 parent 293afcd5ee
commit c160788678
1 file changed
+24
+24
View File
@@ -267,3 +267,27 @@ sync_account() {
args+=($extra_opts)
fi
# Capture the real exit status. Reading $? after an `if` block returns the
# status of the `if` itself (always 0), which silently reported every
# failure as exit 0 and let sync_all treat it as success.
sync_exit=0
imapsync "${args[@]}" >> "$logfile" 2>&1 || sync_exit=$?
if [ "$sync_exit" -eq 0 ]; then
log "Account $i: SYNC OK"
echo "$(date +%s)" > "${LOG_DIR}/account${i}.last_success"
SYNC_ACCOUNT_RESULT="success"
rm -f "$pidfile"
return 0
fi
log "Account $i: SYNC FAILED (exit $sync_exit)"
echo "$(date +%s)" > "${LOG_DIR}/account${i}.last_failure"
if [ "$src_auth" = "oauth2" ] && [ "$oauth_authorization_detected" = "false" ]; then
log_oauth_authorization_guidance "$i" "$src_provider" "$logfile"
fi
SYNC_ACCOUNT_RESULT="failure"
rm -f "$pidfile"
return "$sync_exit"
}