Skip to content

Commit bfbfca0

Browse files
committed
fix: refine directory creation logic in Windows script
- Updated the script to use 'md' for directory creation and improved error handling by logging warnings if directory creation fails. - Ensured that directory checks include a trailing backslash for more reliable path validation.
1 parent b2da074 commit bfbfca0

File tree

1 file changed

+6
-6
lines changed
  • apps/portal/src/app/api/download-agent/scripts

1 file changed

+6
-6
lines changed

apps/portal/src/app/api/download-agent/scripts/windows.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@ echo.
5454
REM Choose a writable directory (primary first, then fallback)
5555
echo Choosing destination directory...
5656
echo Trying primary: %PRIMARY_DIR%
57-
if not exist "%PRIMARY_DIR%" (
58-
mkdir "%PRIMARY_DIR%" >nul 2>&1
57+
if not exist "%PRIMARY_DIR%\" (
58+
md "%PRIMARY_DIR%" 2>nul || echo [WARN] mkdir failed for "%PRIMARY_DIR%"
5959
)
60-
if exist "%PRIMARY_DIR%" set "CHOSEN_DIR=%PRIMARY_DIR%"
60+
if exist "%PRIMARY_DIR%\" set "CHOSEN_DIR=%PRIMARY_DIR%"
6161
if not defined CHOSEN_DIR (
6262
echo Trying fallback: %FALLBACK_DIR%
63-
if not exist "%FALLBACK_DIR%" (
64-
mkdir "%FALLBACK_DIR%" >nul 2>&1
63+
if not exist "%FALLBACK_DIR%\" (
64+
md "%FALLBACK_DIR%" 2>nul || echo [WARN] mkdir failed for "%FALLBACK_DIR%"
6565
)
66-
if exist "%FALLBACK_DIR%" set "CHOSEN_DIR=%FALLBACK_DIR%"
66+
if exist "%FALLBACK_DIR%\" set "CHOSEN_DIR=%FALLBACK_DIR%"
6767
)
6868
6969
if not defined CHOSEN_DIR (

0 commit comments

Comments
 (0)