]> 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>
Fri, 20 May 2016 02:35:33 +0000 (21:35 -0500)
commitf8e97d2c9b9c0d03cd5cc44d7c245bd0349d70c3
treee4fab582bc3c81b956bab55c1de59acdfc70776e
parent97213b1d4d53eaac738d6be2d6dad5315b217e7b
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>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/_helpers.c