
A rewrite of the advanced file download/sync tool zsync.
Note: "zsync2" is a working title which might be changed in the future.
The rewrite changes fundamental principles of how zsync works. For example,the new code will be C++11. Furthermore, the entire functionality will bebundled in a single library called libzsync2. The library will serve as a basefor the new zsync2 main binary, but can then also be linked by other projectswhich seek to make use of the algorithms and functionality in it.
This project is intended to remain compatible to the original zsync, i.e.,the zsync file format will stay the same etc. However, the zsync file formatshould be extended to be able to serve additional purposes as well. Suchpurposes could be e.g., adding meta information like version numbers, etc.
Although the library is written in C++11, it is intended that the headersare compatible to older revisions of the C++ language. Therefore, a patterncalled Opaque Data Type is applied to all classes defined by the headers ofthis library.
To build on Debian or Ubuntu style systems:
sudo apt-get -y install git cmake g++ libssl-dev libssh2-1-dev libcurl4-gnutls-dev zlib1g-dev libgcrypt20-dev git submodule update --initmkdir buildcd buildcmake .. -DUSE_SYSTEM_CURL=1 -DBUILD_CPR_TESTS=0make -j$(nproc)
See.travis.yml for building on Travis CI.
zsync is a well known tool for downloading and updating local files from HTTPservers using the well known algorithms rsync uses for diffing binary files.Therefore, it becomes possible to synchronize modifications by exchanging thechanged blocks locally usingRange: requests.
The system is based on meta files called.zsync files. They contain hashsums for every block of data. The file is generated from and stored alongwith the actual file it refers to. First, the client downloads the meta file.Then, it lets the same algorithms used to generate the meta file hash thelocal file. Then, just like with rsync, both lists of hash sums are compared.Then, modified blocks are fetched from the server, and with the unmodifiedblocks of binary data from the original files, a new file is put together,which eventually replaces the original.
Due to how system works, nothing but a "dumb" HTTP server is required to makeuse of zsync2. This makes it easy to integrate zsync2 into existing systems.
A popular application scenario is software deployment. Here, the popular"update channel" system can be used to describe the update model: For normalupdates (i.e., staying on the same channel), one should call zsync2 with a URLto the.zsync file of the latest release of the application. Withoutadditional effort, zsync2 is then going to update the file accordingly. Onedoes not have to compare meta data to check for updates etc., and informationlike version numbers for example become purely informational for the user, butirrelevant for the actual update process. This makes setting up an updateinfrastructure easier (one just has to set up a static URL to the latestfile).
The original source code has been released under the terms of the ArtisticLicense v2. Since this rewrite is a derivative work, it is published under thesame license. See COPYING for a copy of the license.
Although zsync2 still shares a lot of the code with the original project, it isas of now not functional. While debugging is ongoing, the API is somewhat readyto be used by other projects. The project is therefore published in this stateto allow testing the integration into other projects.