Incomplete files -- NOT a bug

Advertisement

buttersnot
Joined:
Posts:
3
Location:
Canada

Incomplete files -- NOT a bug

Hello people,
I just discovered WinSCP and I'm slowly figuring out the details of how it works. Here's my situation. I have a device that stores files in a folder, fairly continuously. (with pauses of 2–5 minutes between batches of 10–20 files). The storage space on that device is rather small, so I was trying to figure out a way to download & delete. I did come with some code that works quite well, with one exception. If the file being downloaded via WinSCP is still in the process of being written by the device, I only get a partial file (only what's available at the time of download) and then the original gets downloaded.

So since I can delete the partial file, it's most likely not r/o or locked in any way, so I can't relay on that. Files are always different sizes, so I can't rely on size to know when it's done saving.

The only way I can think of to prevent that issue is to go with the timestamp on the file, and process it only if it's older than say 5 minutes, but that seems like a rather inefficient way to handle this.

Anyone have any suggestions?

Thanks!

Reply with quote

Advertisement

buttersnot
Joined:
Posts:
3
Location:
Canada

Hi Martin,
thank you for your response, much appreciated. It is FTP, sorry, I should have mentioned that.

I appreciate the link you sent, that confirms my suspicion that unfortunately there's no locking mechanism of any sort, so I ended up doing this:

Set a timer to scan the folder every 30 seconds. Compare the file timestamp with current time and if it is more than 2 minutes, the file gets processed, otherwise, it sits there until next round. So far, it seems to be working flawlessly.

Reply with quote

Advertisement

You can post new topics in this forum