|
98 |
UCC_IMAGE_INDEX_FILE = 'image-index.txt' |
98 |
UCC_IMAGE_INDEX_FILE = 'image-index.txt' |
99 |
UCC_IMAGE_INDEX_URL = '%s/%s' % (UCC_BASE_URL, UCC_IMAGE_INDEX_FILE) |
99 |
UCC_IMAGE_INDEX_URL = '%s/%s' % (UCC_BASE_URL, UCC_IMAGE_INDEX_FILE) |
100 |
DEFAULT_CHUNK_SIZE = 2**13 |
100 |
DEFAULT_CHUNK_SIZE = 2**13 |
|
|
101 |
BLOCK_SIZE = 4096 # block size is dependent on file system block size for sparse file |
101 |
|
102 |
|
102 |
|
103 |
|
103 |
def _dummy_progress(*args): |
104 |
def _dummy_progress(*args): |
|
165 |
break |
166 |
break |
166 |
|
167 |
|
167 |
uncompressed_data = decompressor.decompress(compressed_data) |
168 |
uncompressed_data = decompressor.decompress(compressed_data) |
168 |
fout.write(uncompressed_data) |
169 |
|
|
|
170 |
# don't write blocks that consist only of 0-bytes to keep sparse file format |
171 |
for i in xrange(0, len(uncompressed_data), BLOCK_SIZE): |
172 |
if len(uncompressed_data[i:i+BLOCK_SIZE]) == BLOCK_SIZE: |
173 |
if uncompressed_data[i:i+BLOCK_SIZE].count('\x00') == BLOCK_SIZE: |
174 |
fout.seek(BLOCK_SIZE, os.SEEK_CUR) |
175 |
else: |
176 |
fout.write(uncompressed_data[i:i+BLOCK_SIZE]) |
177 |
# decompressed data can not be always a multiple of BLOCK_SIZE |
178 |
# so write rest data to avoid data loss |
179 |
else: |
180 |
if uncompressed_data[i:].count('\x00') == len(uncompressed_data[i:]): |
181 |
fout.seek(len(uncompressed_data[i:]), os.SEEK_CUR) |
182 |
else: |
183 |
fout.write(uncompressed_data[i:]) |
184 |
|
169 |
progress(fin.tell(), total_size) |
185 |
progress(fin.tell(), total_size) |
170 |
del compressed_data |
|
|
171 |
del uncompressed_data |
172 |
|
186 |
|
173 |
# check free size on disk every N rounds |
187 |
# check free size on disk every N rounds |
174 |
if counter % 50 == 0: |
188 |
if counter % 50 == 0: |