]> arthur.barton.de Git - bup.git/commit
restore: fix --sparse corruption
authorRob Browning <rlb@defaultvalue.org>
Sun, 24 Apr 2016 16:58:04 +0000 (11:58 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sat, 7 May 2016 19:13:04 +0000 (14:13 -0500)
commit4a49bb58944e1de6228039f536b76f217eb66279
treeb923dae9b9bcbc4d6b8fefb83d539b6beefc77dc
parent8dffb6342ec6880bf5ce5761c5ebb28349c55d78
restore: fix --sparse corruption

Rework the restore --sparse implementation to fix a bug that might cause
it to produce output that didn't match the original input.

Rewrite the code to probe for sparse regions in min_sparse_len jumps,
searching backward from the jump target for a non-zero byte.  If one is
found, move just past that byte and try again.

This should be substantially more efficient than the previous approach
for non-sparse regions.  In the limiting case, it should read roughly
1/min_sparse_len bytes instead of all of them.

The original bug was masked by the fact that the test that would have
revealed it wasn't actually generating random data (across trials),
something that was fixed in "Use $RANDOM seed for --sparse random
tests".

Thanks to Marcus Schopen for reporting the problem and Frank Gevaerts
for helping track down the solution.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/_helpers.c