Waiting time before download starts

Advertisement

Evert
Joined:
Posts:
3
Location:
Netherlands

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()
}

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,453
Location:
Prague, Czechia

Re: Waiting time before download starts

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

Evert
Joined:
Posts:
3
Location:
Netherlands

Reply with logfiles

Hi Martin,

This reply contains one logfiles, from a session with both empty directories.

The other logfile I couldn't add, it can be downloaded from <invalid hyperlink removed by admin>

All sessions are done on a local WiFi network with the FTP server on a QNAP.

Best regards, Evert

Reply with quote

martin
Site Admin
martin avatar

Re: Reply with logfiles

It's the add_FileTransferProgress.
To calculate an operation progress for you, WinSCP has to first determine size of all files to be transferred. You have to chose. If you want the progress, you will have to bear the initial delay.

Reply with quote

Evert
Joined:
Posts:
3
Location:
Netherlands

Thanks for your reply, I'm editing the code but there isn't any progress.

Can you tell me what code I have to edit / delete so the downlaod starts directly?

Kind regards, Evert

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,453
Location:
Prague, Czechia

Evert wrote:

Can you tell me what code I have to edit / delete so the downlaod starts directly?
Delete $session.add_FileTransferProgress( { FileTransferProgress($_) } ) .

If it does not help, post a new log file (for a code with that line deleted).

Reply with quote

Advertisement

You can post new topics in this forum