AutoIt
AutoIt
Get the Files Affected by an FTP Sync
See more FTP Examples
Demonstrates the Chilkat Ftp2.GetSyncedFiles method, which reports the relative paths affected by the most recent synchronization. The only argument is a StringTable that receives the paths (uploaded, downloaded, or deleted).
Background: A sync call reports only overall success, but you usually want to know what actually changed — for logging, for triggering follow-up work on just the new files, or to confirm an incremental sync did the minimal transfer. An empty result is meaningful too: it means everything was already up to date. Call it immediately after the sync, before another operation replaces the recorded list.
Chilkat AutoIt Downloads
Local $bSuccess = False
; Demonstrates the Ftp2.GetSyncedFiles method, which reports the relative paths affected by the
; most recent synchronization operation. The only argument is a StringTable that receives the
; paths.
$oFtp = ObjCreate("Chilkat.Ftp2")
$oFtp.Hostname = "ftp.example.com"
$oFtp.Username = "myFtpLogin"
; Normally you would not hard-code the password in source. You should instead obtain it
; from an interactive prompt, environment variable, or a secrets vault.
$oFtp.Password = "myPassword"
$bSuccess = $oFtp.Connect()
If ($bSuccess = False) Then
ConsoleWrite($oFtp.LastErrorText & @CRLF)
Exit
EndIf
$bSuccess = $oFtp.ChangeRemoteDir("public_html")
If ($bSuccess = False) Then
ConsoleWrite($oFtp.LastErrorText & @CRLF)
Exit
EndIf
; Perform a sync.
Local $iMode = 6
$bSuccess = $oFtp.SyncLocalTree("qa_output/site",$iMode)
If ($bSuccess = False) Then
ConsoleWrite($oFtp.LastErrorText & @CRLF)
Exit
EndIf
; Get the list of files that were uploaded, downloaded, or deleted by that sync.
$oSynced = ObjCreate("Chilkat.StringTable")
$oFtp.GetSyncedFiles $oSynced
Local $iN = $oSynced.Count
ConsoleWrite("Affected files: " & $iN & @CRLF)
Local $i
For $i = 0 To $iN - 1
Local $sRelPath = $oSynced.StringAt($i)
If ($oSynced.LastMethodSuccess = False) Then
ConsoleWrite($oSynced.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite($sRelPath & @CRLF)
Next
$bSuccess = $oFtp.Disconnect()
If ($bSuccess = False) Then
ConsoleWrite($oFtp.LastErrorText & @CRLF)
Exit
EndIf