Differential file saving algorithm or tool

107 views Asked by At

I'm looking for any information or algorithms that allows differential file saving and merging.

To be more clear, I would like when modifying the content of a file the original file should stay the same and every modification made must be saved in a separate file (same thing as differential backup but for files), in case of accessing the file, it should reconstruct the latest version of the file using the original file and the last differential file.

What I need to do is described in the diagram below :

enter image description here

1

There are 1 answers

2
StPiere On

For calculating diffs you could use something like diff_match_patch.

You could store for each file version series of DeltaDiff.

DeltaDiff would be a tuple of one of 2 types: INSERT or DELETE.

Then you could store the series of DeltaDiff as follows:

Diff = [DeltaDiff_1, DeltaDiff_2, ... DeltaDiff_n ] = [

    (INSERT, byteoffset regarding to initial file, bytes)
    (DELETE, byteoffset regarding to initial file, length)
    ....
    (....)
]

Applying the DeltaDiffs to initial file would give you the next file version, and so on, for example:

FileVersion1 + Diff1 -> FileVersion2 + Diff2 -> FileVersion3 + ....