mirror of https://github.com/borgbackup/borg.git
Rename Chunk.meta[compress] => Chunk.meta[compressor]
This commit is contained in:
parent
88647595ac
commit
0c7410104c
|
@ -970,12 +970,12 @@ Utilization of max. archive size: {csize_max:.0%}
|
||||||
if chunks is not None:
|
if chunks is not None:
|
||||||
item.chunks = chunks
|
item.chunks = chunks
|
||||||
else:
|
else:
|
||||||
compress = self.compression_decider1.decide(path)
|
compressor = self.compression_decider1.decide(path)
|
||||||
self.file_compression_logger.debug('%s -> compression %s', path, compress.name)
|
self.file_compression_logger.debug('%s -> compression %s', path, compressor.name)
|
||||||
with backup_io('open'):
|
with backup_io('open'):
|
||||||
fh = Archive._open_rb(path)
|
fh = Archive._open_rb(path)
|
||||||
with os.fdopen(fh, 'rb') as fd:
|
with os.fdopen(fh, 'rb') as fd:
|
||||||
self.chunk_file(item, cache, self.stats, backup_io_iter(self.chunker.chunkify(fd, fh)), compress=compress)
|
self.chunk_file(item, cache, self.stats, backup_io_iter(self.chunker.chunkify(fd, fh)), compressor=compressor)
|
||||||
if not is_special_file:
|
if not is_special_file:
|
||||||
# we must not memorize special files, because the contents of e.g. a
|
# we must not memorize special files, because the contents of e.g. a
|
||||||
# block or char device will change without its mtime/size/inode changing.
|
# block or char device will change without its mtime/size/inode changing.
|
||||||
|
@ -1652,20 +1652,20 @@ class ArchiveRecreater:
|
||||||
self.cache.chunk_incref(chunk_id, target.stats)
|
self.cache.chunk_incref(chunk_id, target.stats)
|
||||||
return item.chunks
|
return item.chunks
|
||||||
chunk_iterator = self.iter_chunks(archive, target, list(item.chunks))
|
chunk_iterator = self.iter_chunks(archive, target, list(item.chunks))
|
||||||
compress = self.compression_decider1.decide(item.path)
|
compressor = self.compression_decider1.decide(item.path)
|
||||||
chunk_processor = partial(self.chunk_processor, target, compress)
|
chunk_processor = partial(self.chunk_processor, target, compressor)
|
||||||
target.chunk_file(item, self.cache, target.stats, chunk_iterator, chunk_processor)
|
target.chunk_file(item, self.cache, target.stats, chunk_iterator, chunk_processor)
|
||||||
|
|
||||||
def chunk_processor(self, target, compress, data):
|
def chunk_processor(self, target, compressor, data):
|
||||||
chunk_id = self.key.id_hash(data)
|
chunk_id = self.key.id_hash(data)
|
||||||
if chunk_id in self.seen_chunks:
|
if chunk_id in self.seen_chunks:
|
||||||
return self.cache.chunk_incref(chunk_id, target.stats)
|
return self.cache.chunk_incref(chunk_id, target.stats)
|
||||||
chunk = Chunk(data, compress=compress)
|
chunk = Chunk(data, compressor=compressor)
|
||||||
overwrite = self.recompress
|
overwrite = self.recompress
|
||||||
if self.recompress and not self.always_recompress and chunk_id in self.cache.chunks:
|
if self.recompress and not self.always_recompress and chunk_id in self.cache.chunks:
|
||||||
# Check if this chunk is already compressed the way we want it
|
# Check if this chunk is already compressed the way we want it
|
||||||
old_chunk = self.key.decrypt(None, self.repository.get(chunk_id), decompress=False)
|
old_chunk = self.key.decrypt(None, self.repository.get(chunk_id), decompress=False)
|
||||||
if Compressor.detect(old_chunk.data).name == compress.name:
|
if Compressor.detect(old_chunk.data).name == compressor.name:
|
||||||
# Stored chunk has the same compression we wanted
|
# Stored chunk has the same compression we wanted
|
||||||
overwrite = False
|
overwrite = False
|
||||||
chunk_entry = self.cache.add_chunk(chunk_id, chunk, target.stats, overwrite=overwrite, wait=False)
|
chunk_entry = self.cache.add_chunk(chunk_id, chunk, target.stats, overwrite=overwrite, wait=False)
|
||||||
|
|
|
@ -12,15 +12,19 @@ which sets the .compressor attribute on the Key.
|
||||||
|
|
||||||
For chunks that emanate from files CompressionDecider1 may set a specific
|
For chunks that emanate from files CompressionDecider1 may set a specific
|
||||||
Compressor based on patterns (this is the --compression-from option). This is stored
|
Compressor based on patterns (this is the --compression-from option). This is stored
|
||||||
as a Compressor instance in the "compress" key in the Chunk's meta dictionary.
|
as a Compressor instance in the "compressor" key in the Chunk's meta dictionary.
|
||||||
|
|
||||||
When compressing either the Compressor specified in the Chunk's meta dictionary
|
When compressing (KeyBase.compress) either the Compressor specified in the Chunk's
|
||||||
is used, or the default Compressor of the key.
|
meta dictionary is used, or the default Compressor of the key.
|
||||||
|
|
||||||
The "auto" mode (e.g. --compression auto,lzma,4) is implemented as a meta Compressor,
|
The "auto" mode (e.g. --compression auto,lzma,4) is implemented as a meta Compressor,
|
||||||
meaning that Auto acts like a Compressor, but defers actual work to others (namely
|
meaning that Auto acts like a Compressor, but defers actual work to others (namely
|
||||||
LZ4 as a heuristic whether compression is worth it, and the specified Compressor
|
LZ4 as a heuristic whether compression is worth it, and the specified Compressor
|
||||||
for the actual compression).
|
for the actual compression).
|
||||||
|
|
||||||
|
Decompression is normally handled through Compressor.decompress which will detect
|
||||||
|
which compressor has been used to compress the data and dispatch to the correct
|
||||||
|
decompressor.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import zlib
|
import zlib
|
||||||
|
|
|
@ -152,7 +152,7 @@ class KeyBase:
|
||||||
|
|
||||||
def compress(self, chunk):
|
def compress(self, chunk):
|
||||||
meta, data = chunk
|
meta, data = chunk
|
||||||
return meta.get('compress', self.compressor).compress(data)
|
return meta.get('compressor', self.compressor).compress(data)
|
||||||
|
|
||||||
def encrypt(self, chunk):
|
def encrypt(self, chunk):
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue