Topic "Error during Session.PutFiles. Files remaining not uploaded."

Author Message
Akarius
[View user's profile]

Joined: 2013-06-21
Posts: 9
Location: Canada
Hi!

This software is awesome! Smile

I have a command line application in VB.NET that transfers a bunch of data files to a remote server once every hour (see code below).

My problem is if an error occurs during the Session.PutFiles function, the upload stops and all the remaining files aren't transfered to the server.

The error I got is:
Quote:
scp: /apps/local/bdq/data/reception/chqc_02MC005_20130620_0815_ecshe.dat: set times: No such file or directory


How can I catch the error but resume the upload for the remaining files?

I'll leave for a long week-end soon but I'll check any reply when I'll get back Thuesday.
Thanks a lot!

Main part of code:
Code:
Public Sub TransfertSCP(scpAtt As scpAccess, xfertpath As String)
   
   Dim sessOpt As New SessionOptions
   With sessOpt
      .Protocol = Protocol.Scp
      .HostName = scpAtt.HostName
      .UserName = scpAtt.UserName
      .SshHostKeyFingerprint = scpAtt.SshHostKeyFingerprint
      .SshPrivateKeyPath = scpAtt.SshPrivateKeyPath
   End With
   Using Session As Session = New Session
      Try
         Session.ExecutablePath = System.AppDomain.CurrentDomain.BaseDirectory() & "ssh\WinSCPnet.exe"

         ' Connect
         Session.Open(sessOpt)
         ' Upload files
         Dim transferOptions As New TransferOptions
         transferOptions.TransferMode = TransferMode.Ascii

         writeLog(app.path_log, app.filename_log, _
                String.Format("Files in {0} to transfer: {1}", xfertpath, Directory.GetFiles(xfertpath).Count), LogLevel.INF)

         Dim transferResult As TransferOperationResult
         transferResult = Session.PutFiles(xfertpath, scpAtt.RemoteFolder, False, transferOptions)

         writeLog(app.path_log, app.filename_log, _
                   String.Format("Files in {0} transfered: {1}", xfertpath, transferResult.Transfers.Count), LogLevel.INF)

         For Each err As SessionRemoteException In transferResult.Failures
            writeLog(app.path_log, app.filename_log, String.Format("ERROR SCP Transfer failed: {0}", err.Message))
         Next

         ' Print transfert
         For Each transfer As TransferEventArgs In transferResult.Transfers
            Console.WriteLine("Upload of {0} succeeded", transfer.FileName)
            writeLog(app.path_log, app.filename_log, String.Format("SCP Transfer successful: {0}", transfer.FileName))
         Next
      Catch ex As Exception
         writeLog(app.path_log, app.filename_log, String.Format("ERROR SCP Transfet {0}", ex.Message))
      End Try
   End Using
End Sub
Advertisements
Akarius
[View user's profile]

Joined: 2013-06-21
Posts: 9
Location: Canada
Here's a log file including the error.

I've replaced sensible parts with * for security reason.

Thanks
SCP_Session_201306240400.log (22.71 KB) [Download]

Description: (none)

Akarius
[View user's profile]

Joined: 2013-06-21
Posts: 9
Location: Canada
I've added this line in the code and it solved the set times: No such file or directory error.
Code:
transferOptions.PreserveTimestamp = False

...but I still want it to continue the remaining uploads if an error occurs and I don't know how I can do this.

I could upload the file one by one but since I have to proceed about 400 files each hour, it'd be too time-consuming.

Any help welcome!
gholmes
[View user's profile]

Joined: 2013-06-25
Posts: 7
Location: United States
I wonder if you could use separate threads? Or would the WinSCP instances step on each other?

(Just reaching ... apologies if the idea is ludicrous for some reason ) Laughing
Akarius
[View user's profile]

Joined: 2013-06-21
Posts: 9
Location: Canada
I could give it a try...in a future version...when I'll have the time Confused

For the moment, it works great.
Quote:
If it ain't broke, don't fix it!
Very Happy

Thanks for the insight.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Akarius wrote:
...but I still want it to continue the remaining uploads if an error occurs and I don't know how I can do this.

WinSCP .NET assembly does not support this. Though in many scenarios the Session.SynchronizeDirectories is good alternative that in principle supports "resuming".
http://winscp.net/eng/docs/library_session_synchronizedirectories
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License