Waiting time before download starts
Hi all,
I like to use WINSCP for sharing software with my colleagues, everybody the same files in the same directories and it's organized on a QNAP NAS.
The whole Powershell script is build and works good when there is less data (4GB) on the NAS, when there is more data on the NAS it takes a long time before the sync is starting, like WINSCP is comparing / indexing both locations.
I've searched the forum, can't figure out how to fix my script that the sync is starter much quicker.
Below is my script, anyone who has a suggestion?
Thanks a lot, Evert
# Load WinSCP .NET assembly
Add-Type -Path "WinSCPnet.dll"
function FileTransferProgress
{
param($e)
Write-Progress `
-Activity "Download status" -Status ("{0:P0} Gedownload:" -f $e.OverallProgress) `
-PercentComplete ($e.OverallProgress * 100)
Write-Progress `
-Id 1 -Activity $e.FileName -Status ("{0:P0} Gedownload:" -f $e.FileProgress) `
-PercentComplete ($e.FileProgress * 100)
}
# Set up session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::FTP
HostName = "FTP SERVER"
PortNumber = 21
UserName = "USERNAME"
Password = "PASSWORD"
FtpSecure = [WinSCP.FtpSecure]::Explicit
TlsHostCertificateFingerprint = "2a:c7:b9:88:2a:d5:dd:ec:54:30:9b:3f:2b:87:25:a3:35:36:80:4e"
Timeout = new-timespan -minutes 5
}
$session = New-Object WinSCP.Session
try
{
# Will continuously report progress of transfer
$session.add_FileTransferProgress( { FileTransferProgress($_) } )
# Connect
$session.Open($sessionOptions)
# Download Files
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
# Sync external to local
$synchronizationResult =
$session.SynchronizeDirectories(
[WinSCP.SynchronizationMode]::Local, "C:\Team-Software", "/Team", $True,
[WinSCP.SynchronizationCriteria]::Size)
# Downloadspeed
Write-Host "Downloaded file $remotePath to $localPath"
Write-Host ("Size {0:N0} KB, Time {1:hh\:mm\:ss}" -f $size, $duration)
Write-Host ("Speed {0:N0} KB/s" -f $speed)
# Throw on any error
$synchronizationResult.Check()
}
finally
{
$session.Dispose()
}
I like to use WINSCP for sharing software with my colleagues, everybody the same files in the same directories and it's organized on a QNAP NAS.
The whole Powershell script is build and works good when there is less data (4GB) on the NAS, when there is more data on the NAS it takes a long time before the sync is starting, like WINSCP is comparing / indexing both locations.
I've searched the forum, can't figure out how to fix my script that the sync is starter much quicker.
Below is my script, anyone who has a suggestion?
Thanks a lot, Evert
# Load WinSCP .NET assembly
Add-Type -Path "WinSCPnet.dll"
function FileTransferProgress
{
param($e)
Write-Progress `
-Activity "Download status" -Status ("{0:P0} Gedownload:" -f $e.OverallProgress) `
-PercentComplete ($e.OverallProgress * 100)
Write-Progress `
-Id 1 -Activity $e.FileName -Status ("{0:P0} Gedownload:" -f $e.FileProgress) `
-PercentComplete ($e.FileProgress * 100)
}
# Set up session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::FTP
HostName = "FTP SERVER"
PortNumber = 21
UserName = "USERNAME"
Password = "PASSWORD"
FtpSecure = [WinSCP.FtpSecure]::Explicit
TlsHostCertificateFingerprint = "2a:c7:b9:88:2a:d5:dd:ec:54:30:9b:3f:2b:87:25:a3:35:36:80:4e"
Timeout = new-timespan -minutes 5
}
$session = New-Object WinSCP.Session
try
{
# Will continuously report progress of transfer
$session.add_FileTransferProgress( { FileTransferProgress($_) } )
# Connect
$session.Open($sessionOptions)
# Download Files
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
# Sync external to local
$synchronizationResult =
$session.SynchronizeDirectories(
[WinSCP.SynchronizationMode]::Local, "C:\Team-Software", "/Team", $True,
[WinSCP.SynchronizationCriteria]::Size)
# Downloadspeed
Write-Host "Downloaded file $remotePath to $localPath"
Write-Host ("Size {0:N0} KB, Time {1:hh\:mm\:ss}" -f $size, $duration)
Write-Host ("Speed {0:N0} KB/s" -f $speed)
# Throw on any error
$synchronizationResult.Check()
}
finally
{
$session.Dispose()
}