Question about remove parameter in GetFiles

Advertisement

ss_doug
Joined:
Posts:
3
Location:
work

Question about remove parameter in GetFiles

Hello,

I have a situation where my application will be downloading files from an sftp server throughout the day, and I've been asked to delete the files after they are downloaded.

The source files on the sftp server can come in at any time, and may or may not have the same filenames as those which have already been downloaded.

My problem scenario is this:
A bunch of files, including "A.txt" are placed in a directory on the sftp server.
My app calls GetFiles to get the contents of the entire directory. The remove parameter is set to True.
At some point during this process - after A.txt is downloaded - a new copy A.txt is placed on the server.
I need to know if the new copy of A.txt will get deleted by the GetFiles method.

Does GetFiles treat the download-then-delete routine as a single, atomic, operation, or is there enough of a time lag between get and remove to cause problems in my scenario?

thanks,
Doug

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,226
Location:
Prague, Czechia

Re: Question about remove parameter in GetFiles

The file is deleted immediately after the download finishes. Though, it is not an atomic operation.

If you need to make it atomic, you need to rename/move the remote file to unique name before download. See Session.MoveFile:
https://winscp.net/eng/docs/library_session_movefile

Reply with quote

Advertisement

You can post new topics in this forum