From 1ce46a4e47653761d807d68d4256d71442c91327 Mon Sep 17 00:00:00 2001 From: onms Date: Thu, 7 May 2026 03:16:54 -0500 Subject: [PATCH] emergency fix for patcher (Darkshade version) --- GameUpdate.bat | 21 +++++++++------------ gameupdate/patch.bat | 21 +++++++++++++++------ gameupdate/patch.sh | 15 +++++++++++---- 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/GameUpdate.bat b/GameUpdate.bat index ab6b767..7610834 100644 --- a/GameUpdate.bat +++ b/GameUpdate.bat @@ -1,14 +1,11 @@ @echo off setlocal - -REM Copy GAMEUPDATE.bat to a new file -copy "gameupdate\patch.bat" "gameupdate\patch2.bat" - -REM Run the new file -call "gameupdate\patch2.bat" - -REM Delete the new file -del "gameupdate\patch2.bat" - -endlocal -@echo on \ No newline at end of file +pushd "%~dp0" +if not exist "gameupdate\patch.bat" ( + echo ERROR: gameupdate\patch.bat not found! + pause + exit /b 1 +) +call "gameupdate\patch.bat" +popd +endlocal \ No newline at end of file diff --git a/gameupdate/patch.bat b/gameupdate/patch.bat index 22b661f..021a442 100644 --- a/gameupdate/patch.bat +++ b/gameupdate/patch.bat @@ -185,9 +185,9 @@ exit /b REM Escape single quotes in paths set "escaped_root=%ROOT_DIR:'=''%" -REM Download zip file to root +REM Download zip file to root via GitLab API (bypasses Cloudflare DDoS protection) echo "Downloading latest patch..." -!_my_shell! -Command "Set-Location -LiteralPath '%escaped_root%'; $ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest -Uri 'https://gitgud.io/%username%/%repo%/-/archive/%branch%/%repo%-%branch%.zip' -OutFile 'repo.zip'" +!_my_shell! -Command "Set-Location -LiteralPath '%escaped_root%'; $ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest -Uri 'https://gitgud.io/api/v4/projects/%username%%%2F%repo%/repository/archive.zip?sha=%branch%' -Headers @{'User-Agent'='git/2.0'} -OutFile 'repo.zip'" if !errorlevel! neq 0 ( pause exit /b @@ -204,11 +204,20 @@ if !errorlevel! neq 0 ( exit /b ) echo "Applying patch..." -xcopy /s /e /y "%ROOT_DIR%\%repo%-%branch%\*" "%ROOT_DIR%\" -if !errorlevel! neq 0 ( +REM API zip uses a different folder name (repo-branch-sha), find it dynamically +set "EXTRACTED_DIR=" +for /d %%D in ("%ROOT_DIR%\%repo%-*") do set "EXTRACTED_DIR=%%D" +if not defined EXTRACTED_DIR ( + echo Patch application failed - extracted folder not found! + del "%ROOT_DIR%\repo.zip" + pause + exit /b +) +robocopy "!EXTRACTED_DIR!" "%ROOT_DIR%" /s /e /xf "GameUpdate.bat" "patch.bat" +if !errorlevel! geq 8 ( echo Patch application failed! del "%ROOT_DIR%\repo.zip" - rmdir /s /q "%ROOT_DIR%\%repo%-%branch%" + rmdir /s /q "!EXTRACTED_DIR!" pause exit /b ) @@ -256,7 +265,7 @@ if exist "%ROOT_DIR%\data.dts" ( REM Clean up echo "Cleaning up..." del "%ROOT_DIR%\repo.zip" -rmdir /s /q "%ROOT_DIR%\%repo%-%branch%" +if defined EXTRACTED_DIR rmdir /s /q "!EXTRACTED_DIR!" del "%ROOT_DIR%\latest_patch_sha.txt" REM Store latest SHA for next check in gameupdate echo %latest_patch_sha% > "%SCRIPT_DIR%previous_patch_sha.txt" diff --git a/gameupdate/patch.sh b/gameupdate/patch.sh index 4986803..0902451 100644 --- a/gameupdate/patch.sh +++ b/gameupdate/patch.sh @@ -80,9 +80,9 @@ if [ -f "$ROOT_DIR/data.dts" ]; then fi download_extract() { - # Download zip file into root + # Download zip file into root via GitLab API (bypasses Cloudflare DDoS protection) echo "Downloading latest patch..." - curl -sL "https://gitgud.io/$username/$repo/-/archive/$branch/$repo-$branch.zip" -o "$ROOT_DIR/repo.zip" + curl -sL -A "git/2.0" "https://gitgud.io/api/v4/projects/$username%2F$repo/repository/archive.zip?sha=$branch" -o "$ROOT_DIR/repo.zip" if [ $? -ne 0 ]; then echo "Download failed!" rm -f "$ROOT_DIR/repo.zip" @@ -101,7 +101,14 @@ download_extract() { fi echo "Applying patch..." - cp -r "$ROOT_DIR/$repo-$branch/"* "$ROOT_DIR/" + # API zip uses a different folder name (repo-branch-sha), find it dynamically + EXTRACTED_DIR=$(find "$ROOT_DIR" -maxdepth 1 -type d -name "${repo}-*" | head -1) + if [ -z "$EXTRACTED_DIR" ]; then + echo "Patch application failed - extracted folder not found!" + rm -f "$ROOT_DIR/repo.zip" + return 1 + fi + cp -r "$EXTRACTED_DIR/"* "$ROOT_DIR/" if [ $? -ne 0 ]; then echo "Patch application failed!" rm -f "$ROOT_DIR/repo.zip" @@ -111,7 +118,7 @@ download_extract() { echo "Cleaning up..." rm -f "$ROOT_DIR/repo.zip" - rm -rf "$ROOT_DIR/$repo-$branch" + [ -n "$EXTRACTED_DIR" ] && rm -rf "$EXTRACTED_DIR" rm -f "$ROOT_DIR/latest_patch_sha.txt" # Store latest SHA for next check in gameupdate