8

I am building an internal iOS application (so - it won't ever be in the app store), and I need to keep a directory of content synchronized between a server and each of the instances of the iOS application. This would be easy enough if I just wanted to delete and re-download this content each time, but I would rather use something similar to rsync to only download the elements that have changed.

I haven't found any good way to utilize rsync. I considered looking at Objective-Git as a possibility here, but at a quick glance it looked like there is still a lot of the support for remote repositories that isn't supported yet.

As a final note, while this won't be in the app store, I will not be jailbreaking these devices and I would prefer to not rely on any private API's (although if there was an elegant solution that utilized private API's I might consider it).

Thoughts?

ADDITIONAL NOTE: This needs to be an isolated solution. I won't be relying on outside services (like Dropbox, Box.net, etc...). This needs to work solely between the device and the server (which is on a local network with the device).

dtuckernet
  • 7,817
  • 5
  • 39
  • 54
  • I appreciate the feedback, however to be honest your answer doesn't really apply here. HTTP + REST isn't a solution - it's just a way that a solution could be implemented. To be honest - both rsync and Objective-Git would solve the problem perfectly if they just were fully functional when compiled for iOS. Both currently have limitations that prevent this from being possible. There are many possible solutions out there - some which use HTTP and some which don't. In the end my main concern is finding something that works. – dtuckernet Oct 22 '12 at 01:25
  • In this case I am using enterprise distribution. You can learn more about it here: https://developer.apple.com/programs/ios/enterprise/ – dtuckernet Oct 22 '12 at 01:25
  • Check this, http://stackoverflow.com/questions/10774924/rsync-directories-vs-files – iDev Oct 23 '12 at 00:39
  • Thanks for that - however, that is just running rsync through Obj-C on OS X. There currently is not a compiled version of rsync (that I've found) that works on iOS. – dtuckernet Oct 23 '12 at 12:24
  • Hi @dtuckernet. Sorry for non-constructive comment, but did you find a solution after all? – Dmitry Makarenko May 07 '13 at 12:24
  • I didn't find a great solution that already exists. I've got on my to-do list to write a syncing solution that uses S3. – dtuckernet May 08 '13 at 01:33
  • Did you find any service or open source project that is useful. I want to achieve the same for Amazon S3 and iOS app? – user3519594 Mar 03 '17 at 12:40

5 Answers5

3

Use HTTP to list the contents of each folder on the server. Compare last modification time of each file with those on the device, and identify added/removed files. Get added and modified files, remove deleted files.

Minthos
  • 900
  • 4
  • 13
  • I appreciate the advice on the approach, but this isn't really a solution (just a generic approach). Many solutions have implemented 'change updates' in one for or another - and it makes sense to utilize one of them instead of writing it from scratch if possible. – dtuckernet Oct 23 '12 at 00:24
1

It sounds like you're maybe asking for a library that already does this, but if you don't find one it's obviously moderately easy to write this from the ground up using stat(2) on the server and the same or a higher-level equivalent on the iOS devices. Have the iPhone send a tree of files with their modification date to the server and get back a list of insert/delete/update operations to do with the url (or whatever) for each one so you can do them incrementally on a background thread. Have the information from the server for new/updated files include the mod date that the server has so you can set it to be the same on the iOS device and send that when asking the server for the status of each file (kind of hack using the file system to store that, but it works).

Dad
  • 6,388
  • 2
  • 28
  • 34
  • 2
    dtuckernet made it pretty clear he was looking for existing solutions, yet the bounty went to another generic approach. – slypete Oct 29 '12 at 01:07
0

Why not just set up a RESTful interface and do it across HTTP; that way you could query the modification times easily enough to determine whether client or server files need to be updated. You might also want to keep track of what files on the client have been synced, so you can easily know which files to add or delete. This can be done with a simple .sync file or using a plist / sqlite / etc.

  • HTTP already includes all stuff for synching a directory, there is no need for a own REST service. – miho Oct 25 '12 at 20:22
0

If you'll consider FTP, there are some pretty advanced client libraries available.

For example, the iOS Chilkat bundle includes an FTP client library that supports synchronization in both directions. It's not free, but it's pretty cheap -- and you get a ton of other stuff that will likely prove useful someday. Here's an example of iOS pulling down all additions and changes (mode 2):

http://www.example-code.com/ios/ftp_syncLocalTree.asp

One caveat -- judging solely from the example, it doesn't appear to synchronize deletions. If this is a requirement, you could do it yourself without too much effort immediately following a sync.

slypete
  • 5,538
  • 11
  • 47
  • 64
0

acrosync (see https://acrosync.com/library.html) seems like a good fit given the initial question, however I haven't used it myself yet.

Philip Jespersen
  • 2,816
  • 2
  • 19
  • 9