Add "Retry" method to QueryReceivedEventArgs Class

Advertisement

Ironpossum
Guest

Add "Retry" method to QueryReceivedEventArgs Class

I'm working through issues with a synchronization automation script and I have found the countless times people have been directed to using the .NET Assembly for more customization. The bottom line is that I need the "Retry" option when a download or directory listing fails during the sync. This option only seems to exist if I'm doing the sync manually. All automation attempts using the built-in scripting or the .NET assembly have fallen flat. I don't want to abort and I don't want to skip - I need to retry.

Additionally, the remote directory has numerous files and subdirectories, so if I just skip any errors and then go back and retry the whole resync, it will fail at a different file or directory, which will never get me a successful sync no matter how many times I try. If I do the sync from the command line and hold "r", I am able to get through the whole sync. Please add a programmatic method to "retry" a failed operation during a sync.

Reply with quote

Advertisement

Ironpossum
Joined:
Posts:
5
Location:
USA

session log

Session log attached as requested.

Note that in the beginning, I did several "retries" and then eventually said "skip all".
  • winscp.log (304.38 KB, Private file)
Description: Note that in the beginning, I did several "retries" and then eventually said "skip all".

Reply with quote

Advertisement

Ironpossum

No idea - not my server. I don't have any control over the remote side, I'm just a client. I can assure you the problem is with the distant end though. I've tested different computers from different networks and it's all the same problem. I cannot get a full sync unless I retry and I cannot retry unless I'm at my computer pressing "r".

Reply with quote

Ironpossum
Joined:
Posts:
5
Location:
USA

I appreciate the pointer, but I'm afraid I'm in over my head. I'm using the powershell example you have created here: https://winscp.net/eng/docs/library_session_synchronizedirectories#powershell

I have modified the session options according to my needs and I changed $session.SynchronizeDirectories to $session.CompareDirectories, but I'm lost on how to error handle if the CompareDirectories fails or even how to move through the ComparisonDifference class or ComparisonDifference.Resolve method. Here's what I have, and I know it's wrong, I just don't know where to go from here:
# Compare Directories
$synchronizationResult = $session.CompareDirectories(
    [WinSCP.SynchronizationMode]::Local, "D:\localdir", "/remotedir/", $true, $true, "Either")
 
# Act?
$ComparisonResult = $synchronizationResult.ComparisonDifference()
$ComparisonResult.Resolve()

I hate to ask you to just solve this for me, but I've seen how many people are asking for a "retry" option, so perhaps it would be beneficial to the community as a whole to add an example script that uses CompareDirectories and ComparisonDifference.Resolve with "retry" error handling the way you're talking about (with PowerShell) to your documentation? I personally would be very grateful.

Reply with quote

Ironpossum
Joined:
Posts:
5
Location:
USA

I kept poking at this and got a little further, but I am still erroring out on the initial $session.CompareDirectories call, because it can't get all the way through the compare. I don't see a way to retry the compare from where it left off - only to retry the compare from the very beginning, which will continue to fail. Here's where I got, even though I never get to the ComparisonDifference section:

# Compare Directories
$synchronizationResult = $session.CompareDirectories(
    [WinSCP.SynchronizationMode]::Local, "D:\localdir", "/remotedir/", $true, $true, "Either")
 
# Act?
$ComparisonResult = $synchronizationResult.ComparisonDifference()
ForEach-Object -InputObject $ComparisonResult {
    $_.Resolve
}

Reply with quote

Advertisement

martin
Site Admin
martin avatar

So are you saying that even Session.CompareDirectories can fail due to that "Bad IP connecting" problem? It other words that even LIST can fail due to that, not only RETR? Because in the log you have posted, the comparison phase succeeded without any problem.[/m]

Reply with quote

Advertisement

You can post new topics in this forum