Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-07

File sync system approach

19 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

aradeonas

[Cross posted on forum so if you want answer there : http://forum.lazarus.freepascal.org/index.php/topic,29007.0.html]

Hi,

For one of my projects I want to send and receive files between server and client and for years I saw demos in Indy,Synapse ... but I wonder if any one done it in real world and have experience or suggestion that want to share with so prevent me to go wrong or reinvent wheel or engine if they are out.

I want to know what is the best approach for making a sync system,what is the powerfullest library and live library,tips to know about security or even file changes recognition and upload just changed part like DropBox.
I don't want all,just if you can help me in some part please do.

Regards

http://www.fastmail.com - Accessible with your email software or over the web

Reply by email

Mark Morgan Lloyd
to aradeonas
aradeonas wrote 16 lines
[Cross posted on forum so if you want answer there : http://forum.lazarus.freepascal.org/index.php/topic,29007.0.html] Hi, For one of my projects I want to send and receive files between server and client and for years I saw demos in Indy,Synapse ... but I wonder if any one done it in real world and have experience or suggestion that want to share with so prevent me to go wrong or reinvent wheel or engine if they are out. I want to know what is the best approach for making a sync system,what is the powerfullest library and live library,tips to know about security or even file changes recognition and upload just changed part like DropBox. I don't want all,just if you can help me in some part please do.

I think that some of this depends on whether you're talking about text or binary files, whether the sharing structure is like a tree or like an arbitrary graph, and the anticipated level of traffic.

One possibility would be to put files into Subversion and either invoke svn or use libsvn (I think somebody was working on a wrapper for this). Another would be to put them into a database (I use this for application-level scripts). Don't use something like a discussion group server, since there could be unexpected indexing problems.

Another possibility would be to look at what a multiuser-aware program like Inkscape uses.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Mark Morgan Lloyd
to aradeonas
aradeonas wrote 5 lines
Thanks. I think database is a better way. Did you know about libraries and better ways for sending and receiving files,both kind,binary and text?

I can't really speak for the non-text situation, and there's a risk that any solution would start giving problems in cases where the number or size of binary files exceeded some arbitrary threshold.

In the case of text, I've typically used TDBMemo or similar for the transfer, although a better solution would be to have a DB-aware TStrings descendant (I don't know whether this exists and is accessible). In the case of at least PostgreSQL and Firebird you can also get at a notification mechanism that allows a program instance to advise others that it's changed something, but doing this requires fiddling with handles directly and might not be portable across Lazarus/FPC versions.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Mark Morgan Lloyd
to aradeonas
aradeonas wrote
About DB I meant use DB for controlling files not storing them but you noticed good points.

Even if your app polls the database server asking if a notification has been issued, it's much less demanding than issuing a full query asking for the timestamp of the most recent file.

I'm doing this on Linux, Solaris and Windows using Postgres, and have done it on (only x86) Linux for Firebird.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Marc Santhoff
to aradeonas: [Cross posted on forum so if you want answer there :…
aradeonas wrote 11 lines
For one of my projects I want to send and receive files between server and client and for years I saw demos in Indy,Synapse ... but I wonder if any one done it in real world and have experience or suggestion that want to share with so prevent me to go wrong or reinvent wheel or engine if they are out. I want to know what is the best approach for making a sync system,what is the powerfullest library and live library,tips to know about security or even file changes recognition and upload just changed part like DropBox. I don't want all,just if you can help me in some part please do.

Maybe it would be a good idea to search for other projects doing the job. How about Owncloud or other server centric application programs? SourceForge or google code and many others are your friend.

Or ask your colleagues or friends, if they know something helpful where you can look at the code.

If you find a library written in plain C it's not so complicated to make an object pascal binding using fpc's h2pas tool.

Additionally you could have a look at relational databases. Locking schemes and replication would be the keywords.

HTH,
Marc

Marc Santhoff

Reply by email

aradeonas
to Marc Santhoff

Database schemes is not a big problem. for me complicity is more in file sending and receiving and dont know a good source in this subject so I asked maybe someone done it or know about.
Or even choosing library for this subject,Indy or synapse or else?

Regards,
Ara

http://www.fastmail.com - Faster than the air-speed velocity of an unladen european swallow

Reply by email

Marc Santhoff
to aradeonas
aradeonas wrote
Database schemes is not a big problem. for me complicity is more in file sending and receiving and dont know a good source in this subject so I asked maybe someone done it or know about. Or even choosing library for this subject,Indy or synapse or else?

OK, you only need sth. for transferring the file from one machine to another? For me SFTP woul be the protocoll of choice, but I don't know what pascal library implements it.

Marc

Marc Santhoff

Reply by email

Lukasz Sokol
to aradeonas
aradeonas wrote 6 lines
Yes,not only but big question. Im reading about SFTP but it seems not to be a good choice for something like OwnCloud or DropBox or ... . From the idea these systems work like, you'd need a bilateral IP connection

from one end to the other, and then (S)FTP protocol working on that, much like OpenVPN or IPSec does, and then some 'automatic' discovery of either end...

Usually for hassle-free establishing of such anonymous tunnel over NATs and firewalls, a helper publicly-available server is required;
In such manner, either end first try to contact the public server and then the public server passes the either-end info around and makes them 'mate' together (much alike Teamviewer or Skype works)

Why?
For either end may be behind NAT or restrictive firewall; Also some NAT/Router/Firewall/Office Gateway solutions tend to run weird port masking/protection schemes; or NAT-T; and then there is the weird (and wonderful...) world of UPNP, where you can request a WAN port of your internet gateway to be forwarded to a port you listen on (in an ideal world, more often than not it ends up being abused by NAS devices that tend to hijack your WAN's port 80 or 443...)

Regards, Ara

el es

Reply by email

Aradeonas
to Lukasz Sokol

Ok.Now I want to work on file sync part and for that I need to choose a library.Indy,Synapse or ... .
What you guys prefer in this case?Synapse is easy to use and I like it but Indy seems larger and more powerful but I didn't work with it. For this case that I need to send and receive files in threads with multi connections it seems I need TCP and there are demos but I want the project stable and no need to rewrite it and maybe there will be need to some p2p connections so I probably I will need to write many things myself and this is not a problem but I want to ask you what library is better in your experience and is there any demos for them in these case or not?

Regards,
Ara

http://www.fastmail.com - The professional email service

Reply by email

Michael Van Canneyt
to Aradeonas
Aradeonas wrote
Ok.Now I want to work on file sync part and for that I need to choose a library.Indy,Synapse or ... . What you guys prefer in this case?Synapse is easy to use and I like it but Indy seems larger and more powerful but I didn't work with it.

I use synapse.
Unless you need some little-used protocol, the overhead and complexity of indy is not worth it.

Michael.

Reply by email

Michael Van Canneyt
to Aradeonas
Aradeonas wrote 5 lines
Thanks. What is the most complicated source you ever seen with Synapse so I can take a look and learn how to control sych systems? Or any demo if you saw any where? I seen some but probably you know more.

I seriously doubt it, it's been a long time since I looked at examples :(

Michael.

Reply by email

Antonio Fortuny
to Aradeonas: Ok.Now I want to work on file sync part and for that I need to choose a…
Aradeonas wrote 17 lines
Ok.Now I want to work on file sync part and for that I need to choose a library.Indy,Synapse or ... . What you guys prefer in this case?Synapse is easy to use and I like it but Indy seems larger and more powerful but I didn't work with it. For this case that I need to send and receive files in threads with multi connections it seems I need TCP and there are demos but I want the project stable and no need to rewrite it and maybe there will be need to some p2p connections so I probably I will need to write many things myself and this is not a problem but I want to ask you what library is better in your experience and is there any demos for them in these case or not? Regards, Ara

Hi Ara.

I'm working with Indy since a long time (Delphi). I've already done such a sync between systems and Lazarus using a multi-threaded approach and mixing platforms like Linux x86, Linux x86_64, Win32, Win64 and WinCE. Indy works on all those platforms, at least, the basic components (WinCE is the smallest one and everything is not implemented).

Anyway all this works in Indy way, using synchronous sockets and threads. It uses blocks as well as streams. Because server sockets work in a separated thread per connection, work is easy (just think processinf a sequential file). I agree on that synapse looks easier and it is easier actually. But because I'm used to Indy since years I always use it when TCP/IP connections are needed (ICMP too) just because I can control every step and I can set and control lots of timeouts.

Unfortunately I cannot show any sample because all library is owned by my previous employer. But it works very well.

Antonio.

Reply by email