login about faq

Hi

We have an application that uses Chilkat SFTP to collect files from various folders on our SFTP server, and occasionally an incomplete file is downloaded which I think is because it is in use at the time by the customer and not yet finished with. I have tried various access and dispositions in the openfile method but it always succeeds in getting a handle on the file, which surprises me.

Is there any way I can check if a file is in the middle of being uploaded by another party before I try and download the file ?

Any help appreciated

Thank you

asked Jan 30 '17 at 06:35

ChrisWard's gravatar image

ChrisWard
1


You could call GetFileSize32 both before and after the download to see if the sized changed during the download. You could also call GetFileSize a short time later to see if the file size changed.

I don't know if there's a way to know if a local process on the remote server also has the file open. The SSH server is the one opening the remote file, and to it the file is local. It's just opening the file, and if the open succeeds, it succeeds.

One thing you might try is to download the file by calling OpenFile w/ an access of "readWrite" to get a handle, then read the file using the handle via the ReadFile* methods, and then close the handle (CloseHandle method). The hope is that the server opens for exclusive access when the access mode is readWrite (as opposed to readOnly). There's nothing in the SFTP protocol that explicitly requests "open for exclusive access" as far as I know (or can remember..).

link

answered Jan 30 '17 at 09:44

chilkat's gravatar image

chilkat ♦♦
12.8k318385539

Hi

Thanks for the input - I will try your suggestions

Chris

link

answered Jan 30 '17 at 10:30

ChrisWard's gravatar image

ChrisWard
1

Is it possible for the creating program to add an extension like .xfr, .filepart, or a temp name, and then rename the file at success create.

you then ignore these files.

link

answered Jan 30 '17 at 15:49

cdlvj130's gravatar image

cdlvj130
12691121

Horrible implementation of file locking on a Windows system. Unix has a command to check file locking. And it even gets worse if file system on a net appliance.

link

answered Jan 30 '17 at 15:52

cdlvj130's gravatar image

cdlvj130
12691121

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×226
×37
×6

Asked: Jan 30 '17 at 06:35

Seen: 780 times

Last updated: Jan 30 '17 at 15:52

powered by OSQA