Session.SynchronizeDirectories() does not detect any change when remote file changes multiple time

Advertisement

squayum
Joined:
Posts:
6
Location:
UK

Session.SynchronizeDirectories() does not detect any change when remote file changes multiple time

I was trying to sync the local server with the remote server using WinSCP library in .NET C# environment (Assembly WinSCPnet, Version=1.5.3.8172, Culture=neutral, PublicKeyToken=2271ec4a3c56d0bf), using the method called Session.SynchronizeDirectories() in Session class. It does not work consistently. I have tried the same sync using WinSCP tool, it works. But I had to set the following parameters to make it work:
  1. Adjust remote time with DST
  2. Time zone offset to 1.
In the software Session class library routine I can’t see a place where you insert this information.
Do you have any idea where time zone offset and DST are set for synchronising directories using Session.SynchronizeDirectories() method?

Reply with quote E-mail

Advertisement

squayum
Joined:
Posts:
6
Location:
UK

Hi Martin,
I have added the following:
SessionObject.AddRawSettings("PreserveTime", "1");
SessionObject.AddRawSettings("ConsiderDST", "1");
I also added: session.AdditionalExecutableArguments = "/ConsiderDST=1 /PreserveTime=1";
Despite that the following method does not detect any file change and transfer the file to local server after 1st time.
File mask was:
TransferOptions options = new TransferOptions() { FileMask = ">2022-04-04" };
transferResult = s.SynchronizeDirectories(SynchronizationMode.Local, ps.t_local, ps.f_remote, true, false, SynchronizationCriteria.Time, options);

Despite that it does not detect remote server file change. It works only 1st time change. It did not work when file changed after 1st time. Do you know the reason why it does not synchronise after 1st time?
Hi have you got any idea why directory synchronization is not working?

Reply with quote E-mail

martin
Site Admin
martin avatar

As with your other question, please post a session log file documenting the problem. Give us a name of a file that we should look for in the log.

Reply with quote

squayum
Joined:
Posts:
6
Location:
UK

Session.SynchronizeDirectories() does not detect any change when remote file changes multiple time

Hi Martin, I have added the winscp log file for you. The file that was changed in the remote server is VMAUN1S0229S2.pkg. The log file detected the changes of VMAUN1S0229S2.pkg, but did not copy the file in the local server. Please see the log for details. Thank you.
Description: WinSCP Session Log

Reply with quote E-mail

Advertisement

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

Re: Session.SynchronizeDirectories() does not detect any change when remote file changes multiple time

The file is downloaded in the first run:
. 2022-04-12 16:40:25.584 Transfer done: 'PLANT2/Data/VMAUN1S0229S2.pkg' => 'C:/ProgramData/CMS/PLANT2/Inbox/data/\VMAUN1S0229S2.pkg' [60]
It's even confirmed by the second run, where the local file obviously have an updated timestamp (although incorrectly, probably because of a timezone/DST mismatch)
. 2022-04-12 16:47:38.198 Local file 'C:/ProgramData/CMS/PLANT2/Inbox/data/\VMAUN1S0229S2.pkg' [2022-04-12T15:34:26.000Z] [60] is modified comparing to remote file 'PLANT2/Data/VMAUN1S0229S2.pkg' [2022-04-12T14:46:49.000Z] [60]
Why are you even using SCP? Use SFTP and you should not have timezone/DST problems.

And the local path should use backslashes (C:\ProgramData\CMS\PLANT2\Inbox\data\), not forward slashes (C:/ProgramData/CMS/PLANT2/Inbox/data/).

Reply with quote

squayum
Joined:
Posts:
6
Location:
UK

Session.SynchronizeDirectories() does not detect any change when remote file changes multiple time

Hi Martin,
I added following to resolve the timezone/ local time problem.
SessionOption.AddRawSettings("PreserveTime", "1");
SessionOption.AddRawSettings("ConsiderDST", "1");
Session.AdditionalExecutableArguments"/ConsiderDST=1 /PreserveTime=1";
1. But this did not fix the problem, it fails to copy the file in the local server after synchronisation. Do you have any library software fix for this problem?

2. You mentioned about using SFTP instead of using SCP to resolve this problem.
Currently I have Assembly WinSCPnet, Version=1.5.3.8172, Culture=neutral, PublicKeyToken=2271ec4a3c56d0bf. Is SFTP part of WinSCPnet, or I need to download different dll? If you could kindly provide some details for this. Thank you.

Reply with quote E-mail

martin
Site Admin
martin avatar

Re: Session.SynchronizeDirectories() does not detect any change when remote file changes multiple time

Yes, WinSCP .NET assembly supports SFTP.

Reply with quote

Advertisement

You can post new topics in this forum