From 5b56e8c1e02b3238173570885e6399e0686f3acc Mon Sep 17 00:00:00 2001 From: "Michael H.G. Schmidt" Date: Mon, 2 Dec 2024 10:12:19 +0100 Subject: [PATCH] bugfix --- software/download-from-ftp.cmd | 63 ++++++++++++++++------------------ 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/software/download-from-ftp.cmd b/software/download-from-ftp.cmd index 8e26c8c..a0680c6 100644 --- a/software/download-from-ftp.cmd +++ b/software/download-from-ftp.cmd @@ -45,10 +45,6 @@ echo FTP_PASS=xxxxxx echo ++++++++++++++++++ echo. -rem cleanup ... -del /F /Q remotesize 2>nul -del /F /Q localsize 2>nul - echo disabling Windows defender for PATH [ %USERPROFILE% ] ... powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath %USERPROFILE% echo. @@ -61,57 +57,56 @@ rem ################################### FOR /F "tokens=1,2 delims=, " %%E in (%LISTFILE%) do ( + call :cleanup + rem get local file size ... FORFILES /M %%F /C "cmd /C echo Content-Length: @fsize >%LOCALSIZE%" - + rem get remote file size ... curl -u %FTP_USER%:%FTP_PASS% -s -I ftp://%FTP_SERVER%/%FTP_PATH%/%%F | findstr Content-Length >%REMOTESIZE% call :compare %%F - ) - -rem ===== -rem END -rem ===== -GOTO END - +GOTO :cleanup +GOTO :END :compare - rem COMPARE both ... - fc /W %LOCALSIZE% %REMOTESIZE% +rem COMPARE both ... +fc /W %LOCALSIZE% %REMOTESIZE% 1>nul 2>nul - if %ERRORLEVEL% GTR 0 ( +if %ERRORLEVEL% GTR 0 ( - rem get it with curl ... - echo. - echo getting: [ %1 ] - curl -u %FTP_USER%:%FTP_PASS% -L ftp://%FTP_SERVER%/%FTP_PATH%/%1 --output %1 - - rem success ? - if NOT EXIST %1 ( - echo ERROR: couldn't get %1! - ) else ( - rem check size (it SHOULD NOT be 0!) - FORFILES /M %1 /C "cmd /C if @fsize EQU 0 echo ERROR: file @relpath is zero size!" - ) + rem get it with curl ... + echo. + echo getting: [ %1 ] + curl -u %FTP_USER%:%FTP_PASS% -L ftp://%FTP_SERVER%/%FTP_PATH%/%1 --output %1 + rem success ? + if NOT EXIST %1 ( + echo ERROR: couldn't get %1! ) else ( - echo OK. File [ %1 ] is same size. - ) + rem check size (it SHOULD NOT be 0!) + FORFILES /M %1 /C "cmd /C if @fsize EQU 0 echo ERROR: file @relpath is zero size!" + ) +) else ( + echo OK. File [ %1 ] is same size. +) goto :eof +:cleanup +del /F /Q remotesize 2>nul +del /F /Q localsize 2>nul +goto :eof :USAGE echo "usage: %0 " echo LISTFILE = basic, browser, optional or other echo. +goto :END +rem ===== +rem END +rem ===== :END -echo. -echo cleanup ... -del /F /Q remotesize 2>nul -del /F /Q localsize 2>nul -echo.