Fixed aes deltatar restoring
authorDaniel Garcia Moreno <danigm@wadobo.com>
Sun, 1 Sep 2013 08:03:10 +0000 (10:03 +0200)
committerDaniel Garcia Moreno <danigm@wadobo.com>
Sun, 1 Sep 2013 08:03:10 +0000 (10:03 +0200)
commit04fb06f49f347319b975be4f5edd196a970bae6a
tree46e2b3e30ac737189be83fd30f31ef8681115e51
parent8edb2e3c95692a2305a1ecc666852dc8e8892b00
Fixed aes deltatar restoring

Test DeltaTarGzipAes256ConcatTest.test_restore_from_index_diff_backup3 was
failing and this patch fixed it.

The encryption was initialized on every call to _init_read_gz and every
time we found a new encryption chunk (something that starts with
"Salted__"). The correct way to do it is to initialize at the beginning and
every time we find a new encryption chunk, it's not needed to initialize
the encryption on every call to _init_read_gz.

There was an exception trying to decompress a chunk of data in the line:

buf = self.cmp.decompress(buf)

This happened because at the end of the file the call to _init_read_gz
fails and the exception is controlled by a try-except, but sometimes just
after this fail there is a call to read the trailing data with the gzip and
a try to decompress and it fails because the self.cmp is not initialized,
this data is garbage, so I catch this exception and everything works okay.
deltatar/tarfile.py