The server does support preserving timestamps. 99% of the time it works just fine. However, I have noticed issues at times where setting the timestamp will fail because the destination file is 'in use'. I suspect that there's an anti-virus scanner that sometimes gets in the way.
I use the
IgnorePermErrors
so that when these errors popup, that the error is skipped rather than aborted. It's worked fine up until I started playing with making my script threaded.
I don't understand why WinSCP is now choosing
"Abort" rather than
"Skip". Is something different with the
$session.CompareDirectories([WinSCP.SynchronizationMode]
$difference.Resolve
syntaxes? Or Am I barking up the wrong tree and there's actually a different command that instructs WinSCP to
Skip rather than
Abort?
Example: Here's a sanitized excerpt from a file that succeeded, then then the next file that failed was skipped. This is from a different script that isn't multithread; it just uses the
$session.SynchronizeDirectories
and that's it.
. 2024-10-27 16:34:00.035 Preserving timestamp [2024-03-01T13:16:16.000Z]
. 2024-10-27 16:34:00.113 Transfer done: '\\<path removed>\SuccessfulFile.xlsx' => '/<Path Removed>/SuccessfulFile.xlsx' [301102]
. 2024-10-27 16:34:00.113 File: '\\<path removed>\FileThatHadIssues.xlsx' [2024-05-15T14:26:14.282Z] [301198]
. 2024-10-27 16:34:00.457 Copying "\\<path removed>\FileThatHadIssues.xlsx" to remote directory started.
. 2024-10-27 16:34:00.753 Preserving timestamp [2024-05-15T14:26:14.000Z]
* 2024-10-27 16:34:00.753 (ETerminal) General failure (server should provide error description).
* 2024-10-27 16:34:00.753 Error code: 4
* 2024-10-27 16:34:00.753 Error message from server (en-US):
* 2024-10-27 16:34:00.753
* 2024-10-27 16:34:00.753 Common reasons for the Error code 4 are:
* 2024-10-27 16:34:00.753 - Renaming a file to a name of already existing file.
* 2024-10-27 16:34:00.753 - Creating a directory that already exists.
* 2024-10-27 16:34:00.753 - Moving a remote file to a different filesystem (HDD).
* 2024-10-27 16:34:00.753 - Uploading a file to a full filesystem (HDD).
* 2024-10-27 16:34:00.753 - Exceeding a user disk quota.
. 2024-10-27 16:34:00.753 Asking user:
. 2024-10-27 16:34:00.753 **Upload of file 'FileThatHadIssues.xlsx' was successful, but error occurred while setting the permissions and/or timestamp.**
. 2024-10-27 16:34:00.753
. 2024-10-27 16:34:00.753 If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on 'Ignore permission errors' option. ("General failure (server should provide error description).
. 2024-10-27 16:34:00.753 Error code: 4
. 2024-10-27 16:34:00.753 Error message from server (en-US):
. 2024-10-27 16:34:00.753
. 2024-10-27 16:34:00.753 Common reasons for the Error code 4 are:
. 2024-10-27 16:34:00.753 - Renaming a file to a name of already existing file.
. 2024-10-27 16:34:00.753 - Creating a directory that already exists.
. 2024-10-27 16:34:00.753 - Moving a remote file to a different filesystem (HDD).
. 2024-10-27 16:34:00.753 - Uploading a file to a full filesystem (HDD).
. 2024-10-27 16:34:00.753 - Exceeding a user disk quota.")
< 2024-10-27 16:34:00.753 Script: Upload of file 'FileThatHadIssues.xlsx' was successful, but error occurred while setting the permissions and/or timestamp.
< 2024-10-27 16:34:00.753 If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on 'Ignore permission errors' option.
< 2024-10-27 16:34:00.753 Script: General failure (server should provide error description).
< 2024-10-27 16:34:00.753 Error code: 4
< 2024-10-27 16:34:00.753 Error message from server (en-US):
< 2024-10-27 16:34:00.753 Common reasons for the Error code 4 are:
< 2024-10-27 16:34:00.753 - Renaming a file to a name of already existing file.
< 2024-10-27 16:34:00.753 - Creating a directory that already exists.
< 2024-10-27 16:34:00.753 - Moving a remote file to a different filesystem (HDD).
< 2024-10-27 16:34:00.753 - Uploading a file to a full filesystem (HDD).
< 2024-10-27 16:34:00.753 - Exceeding a user disk quota.
. 2024-10-27 16:34:00.753 Answer: Skip