Error 32 Two-way synchronisation with delete with PowerShell

Advertisement

Stay_happy
Joined:
Posts:
7

Error 32 Two-way synchronisation with delete with PowerShell

Hello,
I use this https://winscp.net/eng/docs/library_example_two_way_synchronize_delete for the synch with am SSH server and I keep getting the error 32.
Error: Exception when calling Resolve with 1 argument(s): "The transfer completed successfully, but the temporary file "Appointments Overview SS2017.pdf.filepart" could not be renamed to the target file "Appointments Overview SS2017.pdf". If the problem persists, try turning off transfer continuation support.
System error. Code: 32.
The process cannot access the file because it is used by another process
(Error message translated from German to English)

The Error occurs with pictures and maybe also with other files.
I don't know of any process that accesses the files and no write protection or similar has been set.
The error occurs on different laptops and also when I open PowerShell as admin and also with different folders that contain images.
Error also occurs with deactivated four program
It occurs sometimes after 10 files, sometimes after 30 or more files.
If anyone could help me I would be very grateful.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
38,408
Location:
Prague, Czechia

Re: Error 32 Two-way synchronisation with delete with powershell

There's likely some process on the server that picks the newly uploaded files for some inspection and locks them in the process. That prevents WinSCP from renaming them.
It might be the antivirus.
You might workaround that by disabling transfer to temporary file name. Use TransferOptions.ResumeSupport property.
See also Transfer was successfully finished, but temporary transfer file … could not be renamed to target file name …

Reply with quote

Stay_happy
Joined:
Posts:
7

I can not get it working, please help me

Thank you very much for your answere.

The error occurs when transferring .jpg files from the ssh server to my win laptop.
I don't think it is the anti vieren program because the error occurs even with the guard disabled.
I have tried unsuccessfully to modify this PowerShell script https://winscp.net/eng/docs/library_example_two_way_synchronize_delete properly. So that the sync skips the error and continues with the other files.
I have also tried these approaches without any success:
https://winscp.net/forum/viewtopic.php?t=26829
https://winscp.net/eng/docs/library_example_recursive_download_custom_error_handling
https://winscp.net/eng/docs/library_session_queryreceived
Would it be possible for you to please send me the modified PowerShell script? I would be very grateful for it.

Kind regards

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
38,408
Location:
Prague, Czechia

Re: I can not get it working, please help me

You do not want to ignore the error!
You want to disable the transfer to temporary file name.
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.ResumeSupport = New-Object WinSCP.TransferResumeSupport
$transferOptions.ResumeSupport.State = [WinSCP.TransferResumeSupportState]::Off
 
$difference.Resolve($session, $transferOptions) | Out-Null

Reply with quote

Stay_happy
Joined:
Posts:
7

I can not find the pasage

I can not find this passage
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.ResumeSupport = New-Object WinSCP.TransferResumeSupport
$transferOptions.ResumeSupport.State = [WinSCP.TransferResumeSupportState]::Off
$difference.Resolve($session, $transferOptions) | Out-Null
in this script

Reply with quote

Advertisement

Stay_happy
Joined:
Posts:
7

Thank you a lot, but I have another error

Thank you a lot for the support.
Sometimes during the synchronisation there is a rest of an file that the software can not find. When I search for the file I can't find them too. Only when I copy the complete path from PowerShell and paste it in the Windows 11 explorer, my laptop tries to open the file (so I guess there is something). However it can not open the file and I can not find it in the Windows 11 Explorer.
So how can I modify the synchronisation, to save all errors in a txt and continue even when an error occurs? I want the software to skip the file it can not find. I do not think i can use a mask because I have many diffent files with the problem.

I am using script based on:
https://winscp.net/eng/docs/library_example_two_way_synchronize_delete

Reply with quote

martin
Site Admin
martin avatar

Re: Thank you a lot, but I have another error

Just wrap the $difference.Resolve call in try...catch, log the error and continue.

Reply with quote

Stay_happy
Joined:
Posts:
7

Please help me out, i can not get it running

Could you please build it in this skript? Because i tried a lot but nothing works.
Please use this skript below because I added a exception for ntuser files.
I would be so happy if anyone would help me out because I invested soooo much time in this projekt but I can not get it running.
Thank you a lot.
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.ResumeSupport = New-Object WinSCP.TransferResumeSupport
$transferOptions.ResumeSupport.State = [WinSCP.TransferResumeSupportState]::Off
$transferOptions.AddRawSettings("ExcludeHiddenFiles", "1")
$transferOptions.FileMask = "*.* | printru.ini"#habe ich nachträglich hinzugefügt
$transferOptions.FileMask = "*.* | Desktop.ini"; #habe (ich) nachträglich hinzugefügt
$transferOptions.FileMask = "*.* | ntuser.dat";    #habe ich nachträglich hinzugefügt
 
$difference.Resolve($session, $transferOptions) | Out-Null

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
38,408
Location:
Prague, Czechia

Re: Please help me out, i can not get it running

See how continueOnError is implemented in:
Keep local directory up to date (download changed files from remote SFTP/FTP server)
try
{
    $difference.Resolve($session) | Out-Null
}
catch
{
    Write-Host -ForegroundColor Red $_.Exception.Message
    [System.Console]::Beep()
}

Additionally, your code that sets FileMask three times makes no sense. You just overwrite the previous value. You have to set all your three exclusions in one mask:
$transferOptions.FileMask = "| printru.ini, Desktop.ini, ntuser.dat"

Reply with quote

Stay_happy
Joined:
Posts:
7

Could you please impelment it in the script? I do not know how

I have no idea what I have to do regarding the $difference.Resolve.

Could you please implement it in the script for me? I do not know how.
Thank you a lot for your help.

Reply with quote

martin
Site Admin
martin avatar

Re: Could you please impelment it in the script? I do not know how

I do not know what else should I do for you.
What's so complicated about replacing the $difference.Resolve($session) line with the code from my previous post?

Reply with quote

Advertisement

You can post new topics in this forum