Igor
Igor

Reputation: 1640

Writing a patcher application for automatic updates of certain files

I've read a couple of questions and answers on SO before I finally decided to post the question myself.

My aim is to write a patcher, which checks certain content against some location with up-to-date files. It'd be best if it could download and upload as little as possible, but detect modified files and replace either complete files or - preferably - only binary deltas.

I thought about making checksums of chunks on the server-side and checking against them on the client and only getting those chunks, that have different checksums.

What I really want to know is the theoretical approach, because I read a bit into VCDIFF and other approaches, but I am not sure I understand them. Is there a common approach to this sort of question? Is the chunk-idea correct? How would I go about implementing it in C# or Java?

Thank you in advance!

Upvotes: 2

Views: 499

Answers (1)

Patrick Hofman
Patrick Hofman

Reputation: 156928

Depending on the type of files (text, binary) you can use a diff algorithm to narrow down the changes you have to send.

One of our interns has done a study on version control management, and he came up with a diff algorithm based on some studies. Maybe it is useful to you.

You can find some literature over here:

  1. E. Myers, „An O(ND) Difference Algorithm and Its Variations,” Algorithmica, p. 15, 1986.
  2. mmanela, „Diffplex,” http://diffplex.codeplex.com/releases/view/66796.

If you want to send over files, I would go at least for checksum and length, since these are most certainly unique.

You could create a format like

  • filename
  • checksum
  • length

Post it to the server. Let it return the changes if:

  1. The file wasn't on the client yet
  2. The checksum or length is different

In all other cases, leave it.

Upvotes: 2

Related Questions