From dd3a690cb48556c5ed8dff1584667a2e2ce04714 Mon Sep 17 00:00:00 2001 From: Lixian Zhou Date: Mon, 9 Mar 2026 15:17:38 -0400 Subject: [PATCH] fix --- .DS_Store | Bin 18436 -> 18436 bytes .gitea/workflows/deploy-main.yml | 56 +++++++++++++----- app/.DS_Store | Bin 28676 -> 28676 bytes .../trans-routes/RoutesDashboard.js | 48 +-------------- 4 files changed, 43 insertions(+), 61 deletions(-) diff --git a/.DS_Store b/.DS_Store index bc6562e2b5bd3a7d1bff59652c99b233e77aa6d5..6b3a623281ba50657ad798b66cbc2c5c9bbee4ed 100644 GIT binary patch delta 1187 zcmb7@Z){Ul7{=e{^maSfTeiD)p%Zs)$FQwkH`@({h#AZN!~q?1YztUmOSj&Q#;%=h zokIh|1cMROnUiS5e~F1Ge$eT4htJNAOdO7=;@2{V<v2lJaDV6XD0~ z8$;ff7Euwb744CA+V$0=k+rI}%GkC0zSy3Ty1pOFnFt&bdR2sCrHvyg!*50x3L*Y0TgN4&f*s#}haf#WOg87w{5Z#!0-5 zdAx(O_z)lA6P(9I{D4cij4QZ`W&FWZ=47?ZV7D?q3$P$-U~Oy*>tX#Y#zxqFabbP^ zs_SAxap6_GGAN#VdbV!c9{qPvpo%3W$u-ZABxTNsL(Mg_dU+ude6i-{HMi8Q)jYag zf-6a%U&=BGtt1;l9*@psR!TA)@o2hDCP6LsZU{+<6|w0qP16;biBhf2kdjtJN2lDT z0GRW7BJrxr_dl6@N?*}8bcwD=CV#;O4mZ5;AtV{Jp#oG9zYh4;2>sk7>`OO$3u7$PvJQ{FS)!Z$(+O+IE6Q1VFB;s3_d6l`W#>5JNzil z1w6*@H$Gm9PY-0%sZ4r8`VbE9X7PG>=Emo2+3NguYku`1y14AZ5DnlMaNltND!Dc~@#mtipTv%9{K+>Bpo1JBn zWCg2CVMt^sVMr_sF3QWv&r1i2F>Vf%> "$CHANGED_LIST_FILE" + done < <(git diff --name-only --diff-filter=ACMRT "$BEFORE_SHA" "$AFTER_SHA" -- "${CHANGE_PATHS[@]}" || true) + + while IFS= read -r file; do + [ -z "$file" ] && continue + is_excluded_path "$file" && continue + printf '%s\n' "$file" >> "$DELETED_LIST_FILE" + done < <(git diff --name-only --diff-filter=D "$BEFORE_SHA" "$AFTER_SHA" -- "${CHANGE_PATHS[@]}" || true) else - CHANGED_FILES=$(git show --name-only --pretty="" "$AFTER_SHA" -- "${CHANGE_PATHS[@]}" | rg -v "$EXCLUDE_PATTERN" || true) - DELETED_FILES="" + while IFS= read -r file; do + [ -z "$file" ] && continue + is_excluded_path "$file" && continue + [ -f "$file" ] || continue + printf '%s\n' "$file" >> "$CHANGED_LIST_FILE" + done < <(git show --name-only --pretty="" "$AFTER_SHA" -- "${CHANGE_PATHS[@]}" || true) fi - if [ -z "$CHANGED_FILES" ]; then + if [ ! -s "$CHANGED_LIST_FILE" ]; then echo "No backend file changes detected in target folders." else while IFS= read -r file; do [ -z "$file" ] && continue - [ -f "$file" ] || continue - remote_file="$REMOTE_APP_ROOT/$file" - remote_dir=$(dirname "$remote_file") - $SSH_CMD "$REMOTE_USER@$REMOTE_HOST" "sudo mkdir -p \"$remote_dir\"" - rsync -az --exclude ".DS_Store" --exclude "_MACOSX" --rsync-path="sudo rsync" -e "$RSYNC_RSH" "$file" "$REMOTE_USER@$REMOTE_HOST:$remote_file" - echo "Deployed: $file" - done <<< "$CHANGED_FILES" + printf '%s\n' "$(dirname "$file")" + done < "$CHANGED_LIST_FILE" | awk '!seen[$0]++' > "$DIRS_LIST_FILE" + + while IFS= read -r dir; do + [ -z "$dir" ] && continue + $SSH_CMD "$REMOTE_USER@$REMOTE_HOST" "sudo mkdir -p \"$REMOTE_APP_ROOT/$dir\"" + done < "$DIRS_LIST_FILE" + + rsync -az --files-from="$CHANGED_LIST_FILE" --exclude ".DS_Store" --exclude "_MACOSX" --rsync-path="sudo rsync" -e "$RSYNC_RSH" ./ "$REMOTE_USER@$REMOTE_HOST:$REMOTE_APP_ROOT/" + echo "Deployed backend changes from CHANGE_PATHS." fi - if [ -n "$DELETED_FILES" ]; then + if [ -s "$DELETED_LIST_FILE" ]; then while IFS= read -r file; do [ -z "$file" ] && continue remote_file="$REMOTE_APP_ROOT/$file" $SSH_CMD "$REMOTE_USER@$REMOTE_HOST" "sudo rm -f \"$remote_file\"" echo "Deleted on remote: $file" - done <<< "$DELETED_FILES" + done < "$DELETED_LIST_FILE" fi + + rm -f "$CHANGED_LIST_FILE" "$DELETED_LIST_FILE" "$DIRS_LIST_FILE" diff --git a/app/.DS_Store b/app/.DS_Store index 1ff97b5b168480e098313cf47b18cedcd50c8aad..f0385b8afc988e06752d350adf8fe8dd252335f3 100644 GIT binary patch delta 69 zcmZp9z}WJDaf6oS { const [routesForShowing, setRoutesForShowing] = useState(allRoutes); const [routesInboundForShowing, setRoutesInboundForShowing] = useState(inboundRoutes); const [routesOutboundForShowing, setRoutesOutboundForShowing] = useState(outboundRoutes); - const previousAbsentCustomerIdsRef = useRef(new Set()); - const isUpdatingAbsentRef = useRef(false); const [isLoading, setIsLoading] = useState(false); const [errorMessage, setErrorMessage] = useState(undefined); @@ -481,50 +479,6 @@ const RoutesDashboard = () => { }); }); - // Only update backend if absent customer list has changed and not already updating - const previousIds = previousAbsentCustomerIdsRef.current; - const hasAbsentCustomersChanged = - absentCustomerIds.size !== previousIds.size || - [...absentCustomerIds].some(id => !previousIds.has(id)) || - [...previousIds].some(id => !absentCustomerIds.has(id)); - - if (hasAbsentCustomersChanged && !isUpdatingAbsentRef.current) { - // Update ref immediately (synchronous) to prevent re-entry - previousAbsentCustomerIdsRef.current = absentCustomerIds; - isUpdatingAbsentRef.current = true; - - // Collect routes that need updating - const routesToUpdate = []; - outboundRoutes.forEach(outboundRoute => { - const filteredCustomerList = outboundRoute.route_customer_list?.filter(customer => - !absentCustomerIds.has(customer.customer_id) - ) || []; - - if (filteredCustomerList.length !== outboundRoute.route_customer_list?.length) { - routesToUpdate.push({ - id: outboundRoute.id, - data: { ...outboundRoute, route_customer_list: filteredCustomerList } - }); - } - }); - - // Batch update via direct API calls, then refetch once - if (routesToUpdate.length > 0) { - Promise.all(routesToUpdate.map(r => TransRoutesService.updateRoute(r.id, r.data))) - .then(() => { - dispatch(fetchAllRoutes()); - }) - .catch(err => { - console.error('Error batch-updating outbound routes:', err); - }) - .finally(() => { - isUpdatingAbsentRef.current = false; - }); - } else { - isUpdatingAbsentRef.current = false; - } - } - // Remove absent customers from outbound routes for display const processedOutboundRoutes = outboundRoutes.map(outboundRoute => ({ ...outboundRoute, @@ -534,7 +488,7 @@ const RoutesDashboard = () => { })); return processedOutboundRoutes; - }, [dispatch, fetchAllRoutes]) + }, []) useEffect(() => { setPageLoading(true);