new download ftp script
This commit is contained in:
parent
d4396908a8
commit
f36aa141f1
2
software/.gitignore
vendored
2
software/.gitignore
vendored
@ -15,4 +15,6 @@
|
|||||||
*.part
|
*.part
|
||||||
*.key
|
*.key
|
||||||
*.ttf
|
*.ttf
|
||||||
|
remotesize
|
||||||
|
localsize
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
@echo off
|
@echo off
|
||||||
set FTPSETTINGS=..\custom\ftpsettings.cmd
|
set FTPSETTINGS=..\custom\ftpsettings.cmd
|
||||||
|
set LOCALSIZE=localsize
|
||||||
|
set REMOTESIZE=remotesize
|
||||||
|
|
||||||
rem ===================
|
rem ===================
|
||||||
rem CONFIGFILE CHECK
|
rem CONFIGFILE CHECK
|
||||||
@ -43,6 +45,10 @@ echo FTP_PASS=xxxxxx
|
|||||||
echo ++++++++++++++++++
|
echo ++++++++++++++++++
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
|
rem cleanup ...
|
||||||
|
del /F /Q remotesize 2>nul
|
||||||
|
del /F /Q localsize 2>nul
|
||||||
|
|
||||||
echo disabling Windows defender for PATH [ %USERPROFILE% ] ...
|
echo disabling Windows defender for PATH [ %USERPROFILE% ] ...
|
||||||
powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath %USERPROFILE%
|
powershell -inputformat none -outputformat none -NonInteractive -Command Add-MpPreference -ExclusionPath %USERPROFILE%
|
||||||
echo.
|
echo.
|
||||||
@ -55,24 +61,13 @@ rem ###################################
|
|||||||
|
|
||||||
FOR /F "tokens=1,2 delims=, " %%E in (%LISTFILE%) do (
|
FOR /F "tokens=1,2 delims=, " %%E in (%LISTFILE%) do (
|
||||||
|
|
||||||
IF NOT EXIST %%F (
|
rem get local file size ...
|
||||||
|
FORFILES /M %%F /C "cmd /C echo Content-Length: @fsize >%LOCALSIZE%"
|
||||||
|
|
||||||
rem get it with curl ...
|
rem get remote file size ...
|
||||||
echo.
|
curl -u %FTP_USER%:%FTP_PASS% -s -I ftp://%FTP_SERVER%/%FTP_PATH%/%%F | findstr Content-Length >%REMOTESIZE%
|
||||||
echo getting: [ %%F ]
|
|
||||||
curl -u %FTP_USER%:%FTP_PASS% -L ftp://%FTP_SERVER%/%FTP_PATH%/%%F --output %%F
|
|
||||||
|
|
||||||
rem success ?
|
call :compare %%F
|
||||||
if NOT EXIST %%F (
|
|
||||||
echo ERROR: couldn't get %%F!
|
|
||||||
) ELSE (
|
|
||||||
rem check size (it SHOULD NOT be 0!)
|
|
||||||
FORFILES /M %%F /C "cmd /C if @fsize EQU 0 echo ERROR: file @relpath is zero size!"
|
|
||||||
)
|
|
||||||
|
|
||||||
) ELSE (
|
|
||||||
FORFILES /M %%F /C "cmd /C if @fsize NEQ 0 echo OK: file @relpath is [ @fsize ] bytes"
|
|
||||||
)
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -81,10 +76,42 @@ rem END
|
|||||||
rem =====
|
rem =====
|
||||||
GOTO END
|
GOTO END
|
||||||
|
|
||||||
|
|
||||||
|
:compare
|
||||||
|
rem COMPARE both ...
|
||||||
|
fc /W %LOCALSIZE% %REMOTESIZE%
|
||||||
|
|
||||||
|
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!"
|
||||||
|
)
|
||||||
|
|
||||||
|
) else (
|
||||||
|
echo OK. File [ %1 ] is same size.
|
||||||
|
)
|
||||||
|
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
|
||||||
:USAGE
|
:USAGE
|
||||||
echo "usage: %0 <LISTFILE>"
|
echo "usage: %0 <LISTFILE>"
|
||||||
echo LISTFILE = basic, browser, optional or other
|
echo LISTFILE = basic, browser, optional or other
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
:END
|
:END
|
||||||
|
echo.
|
||||||
|
echo cleanup ...
|
||||||
|
del /F /Q remotesize 2>nul
|
||||||
|
del /F /Q localsize 2>nul
|
||||||
|
echo.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user