How does SYNC handle open server files actively being written to?

Advertisement

redrob
Joined:
Posts:
3
Location:
Buffalo, NY

How does SYNC handle open server files actively being written to?

I'm about to build an automation that:
  1. grabs new files from an FTP server
  2. puts them in a local dropbox folder
  3. dropbox client will automatically upload them (sync) with Dropbox (online) which will trigger other actions
This seems trivial with WinSCP's Synchronize, right?

My question is -- how does Synchronize deal with open files that are actively being written to on the FTP server?

The FTP folder I'm pulling files from is on a video recording device (ATEM Mini Pro) which is saving live videos, sequentially numbered, to its locally attached drive which is network-accessible via FTP. I don't want to download (and subsequently have uploaded to Dropbox) incomplete and invalid video files which are not yet saved/committed.

Thank you for any insights!

Reply with quote

Advertisement

redrob
Joined:
Posts:
3
Location:
Buffalo, NY

Any ideas?

I tested with two FTP clients (Windows explorer, and command-line FTP utility) and sadly, they both can see the files on my FTP server (the ATEM device) which still open, and actively being written to. Not only that, they can GET the open files (unusable, and corrupt video files as I suspected) AND it messes up the device in the process and the saved files on the server are corrupt afterwards too!

So – is there any solution to this? Can WinSCP's synch look at the timestamp, or file size on a server file – perhaps 'n' # of times before downloading it, and NOT downloading it if either size or timestamp has changed between looks? Something like:
  • GET folder contents (contents A)
  • Wait 'n' seconds
  • GET folder contents again (contents B)
  • DIFF the two. For all files that are the same, MGET those files [if they don't already exist in the local folder (depending on the sync options)]

Reply with quote

redrob
Joined:
Posts:
3
Location:
Buffalo, NY

Re: How does SYNC handle open server files actively being written to?

martin wrote:

This more about, how does the FTP server handle that.
While the server definitely is responsible for how it names files, and does (or doesn't) give them temporary/working names while they are actively being written to, I don't agree this is a server-only topic. A search on the Web will show this has long been a problem with FTP.
  1. I find it odd the server keeps writing while the client reads the same file
  2. I find it odd both the server-side AND client-side files are corrupt and unusable if I GET the files while they are actively being written to
  3. WinSCP has a REALLY nice looking, and robust Synch capability. What I'm suggesting is that it would be super-awesome if that feature set included accommodations for what seems to be a prolific and pervasive problem.
I coded a working solution that does not involve WinSCP using an algorithm/technique someone else suggested on the net, involving doing a DIR.. waiting.. doing another DIR.. DIFF-ing the two, creating a list of files that have not changed size/date/etc. GET that list of files only.
It works – active files are not downloaded.

Seems like something that could be part of WinSCP synch. A checkbox "[ ] Only Download IDLE server-side files".

Reply with quote

martin
Site Admin
martin avatar

Re: How does SYNC handle open server files actively being written to?

Do you have a suggestion, how should WinSCP detect that a file is "idle"?

Reply with quote

Advertisement

Guest

Re: How does SYNC handle open server files actively being written to?

Yes.. algorithmically like I described above, by comparing the output of two time-separated DIR commands; files in both listings with identical attributes are "idle"

Reply with quote

martin
Site Admin
martin avatar

Re: How does SYNC handle open server files actively being written to?

OK, I will see, if more people ask for this.

Reply with quote

Advertisement

You can post new topics in this forum