MAX_VOLUME_BLOCKS = N_BLOCKS_PER_RECORD + 1
#: size of big file: fits into first volume even if not compressed
-BIG_SIZE = (MAX_VOLUME_BLOCKS-3) * BLOCKSIZE
+BIG_SIZE = (MAX_VOLUME_BLOCKS-4) * BLOCKSIZE
#: max size of small files
SMALL_MAX_SIZE = 2 * BLOCKSIZE
HASH_BUF_SIZE = 4096
#: modes for tar file creation
-CREATE_MODES = 'w:tar', 'w|tar', 'w|gz', 'w|bz2', 'w#gz'
+CREATE_MODES = 'w:tar', 'w|tar', 'w|gz', 'w|bz2', 'w#gz', \
#'w#gz.aes128', 'w#gz.aes256', 'w#aes128', 'w#aes256'
# not currently working: 'w:gz', 'w:bz2',
output = []
if print_everything:
print('-' * 72)
- prefix = '{:9d}: '.format(seed)
+ prefix = '{:10d}: '.format(seed)
dprnt = lambda val: print(prefix + val)
else:
dprnt = output.append
# add big file
big_name, big_hash, file_info = create_file(BIG_SIZE, temp_dir)
- files[big_name] = big_hash
+ files[big_name] = (big_hash, BIG_SIZE)
dprnt('adding big file {} of size {}, info {} with hash {}'
.format(big_name, BIG_SIZE, file_info, big_hash))
tarobj.add(big_name, arcname=basename(big_name))
small_size = random.randint(0, SMALL_MAX_SIZE)
small_name, small_hash, file_info = create_file(small_size,
temp_dir)
- files[small_name] = small_hash
+ files[small_name] = (small_hash, small_size)
dprnt('adding small file {} of size {}, info {} with hash {}'
.format(small_name, small_size, file_info, small_hash))
tarobj.add(small_name, arcname=basename(small_name))
for file_name in os.listdir(temp_dir):
dprnt('listdir: {}'.format(file_name))
- for file_name, file_hash in files.items():
+ for file_name, (file_hash, file_size) in files.items():
if not os.path.exists(file_name):
everything_ok = False
dprnt('failed to find file {} after extraction'
.format(file_name))
continue
+ if os.stat(file_name).st_size != file_size:
+ everything_ok = False
+ dprnt('wrong size for file {} after extraction: {} != {}'
+ .format(file_name, os.stat(file_name).st_size,
+ file_size))
+ continue
if hash_file(file_name) != file_hash:
everything_ok = False
dprnt('wrong hash for file {} after extraction: {} != {}'
pass
if (not print_everything) and (not everything_ok):
- prefix = '{:9d}: '.format(seed)
+ prefix = '{:10d}: '.format(seed)
for line in output:
print(prefix + line)
elif print_everything and everything_ok: