Topic "Question about remove parameter in GetFiles"

Author Message
ss_doug
[View user's profile]

Joined: 2012-07-24
Posts: 3
Location: work
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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
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:
http://winscp.net/eng/docs/library_session_movefile
ss_doug
[View user's profile]

Joined: 2012-07-24
Posts: 3
Location: work
Hi,

Thanks for the quick response and move/rename suggestion.

Doug
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