mirror of
https://github.com/borgbackup/borg.git
synced 2026-06-09 08:51:54 -04:00
Rename CompressionDecider1 -> CompressionDecider
This commit is contained in:
parent
0c7410104c
commit
d1826cca92
4 changed files with 13 additions and 13 deletions
|
|
@ -36,7 +36,7 @@ from .helpers import bin_to_hex
|
|||
from .helpers import safe_ns
|
||||
from .helpers import ellipsis_truncate, ProgressIndicatorPercent, log_multi
|
||||
from .helpers import PathPrefixPattern, FnmatchPattern
|
||||
from .helpers import CompressionDecider1
|
||||
from .helpers import CompressionDecider
|
||||
from .item import Item, ArchiveItem
|
||||
from .key import key_factory
|
||||
from .platform import acl_get, acl_set, set_flags, get_flags, swidth
|
||||
|
|
@ -310,8 +310,8 @@ class Archive:
|
|||
self.file_compression_logger = create_logger('borg.debug.file-compression')
|
||||
self.items_buffer = CacheChunkBuffer(self.cache, self.key, self.stats)
|
||||
self.chunker = Chunker(self.key.chunk_seed, *chunker_params)
|
||||
self.compression_decider1 = CompressionDecider1(compression or CompressionSpec('none'),
|
||||
compression_files or [])
|
||||
self.compression_decider = CompressionDecider(compression or CompressionSpec('none'),
|
||||
compression_files or [])
|
||||
if name in manifest.archives:
|
||||
raise self.AlreadyExists(name)
|
||||
self.last_checkpoint = time.monotonic()
|
||||
|
|
@ -970,7 +970,7 @@ Utilization of max. archive size: {csize_max:.0%}
|
|||
if chunks is not None:
|
||||
item.chunks = chunks
|
||||
else:
|
||||
compressor = self.compression_decider1.decide(path)
|
||||
compressor = self.compression_decider.decide(path)
|
||||
self.file_compression_logger.debug('%s -> compression %s', path, compressor.name)
|
||||
with backup_io('open'):
|
||||
fh = Archive._open_rb(path)
|
||||
|
|
@ -1582,8 +1582,8 @@ class ArchiveRecreater:
|
|||
self.always_recompress = always_recompress
|
||||
self.compression = compression or CompressionSpec('none')
|
||||
self.seen_chunks = set()
|
||||
self.compression_decider1 = CompressionDecider1(compression or CompressionSpec('none'),
|
||||
compression_files or [])
|
||||
self.compression_decider = CompressionDecider(compression or CompressionSpec('none'),
|
||||
compression_files or [])
|
||||
|
||||
self.dry_run = dry_run
|
||||
self.stats = stats
|
||||
|
|
@ -1652,7 +1652,7 @@ class ArchiveRecreater:
|
|||
self.cache.chunk_incref(chunk_id, target.stats)
|
||||
return item.chunks
|
||||
chunk_iterator = self.iter_chunks(archive, target, list(item.chunks))
|
||||
compressor = self.compression_decider1.decide(item.path)
|
||||
compressor = self.compression_decider.decide(item.path)
|
||||
chunk_processor = partial(self.chunk_processor, target, compressor)
|
||||
target.chunk_file(item, self.cache, target.stats, chunk_iterator, chunk_processor)
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ Borg has a flexible scheme for deciding which compression to use for chunks.
|
|||
First, there is a global default set by the --compression command line option,
|
||||
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 CompressionDecider may set a specific
|
||||
Compressor based on patterns (this is the --compression-from option). This is stored
|
||||
as a Compressor instance in the "compressor" key in the Chunk's meta dictionary.
|
||||
|
||||
|
|
|
|||
|
|
@ -2096,7 +2096,7 @@ def clean_lines(lines, lstrip=None, rstrip=None, remove_empty=True, remove_comme
|
|||
yield line
|
||||
|
||||
|
||||
class CompressionDecider1:
|
||||
class CompressionDecider:
|
||||
def __init__(self, compression, compression_files):
|
||||
"""
|
||||
Initialize a CompressionDecider instance (and read config files, if needed).
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ from ..helpers import StableDict, int_to_bigint, bigint_to_int, bin_to_hex
|
|||
from ..helpers import parse_timestamp, ChunkIteratorFileWrapper, ChunkerParams, Chunk
|
||||
from ..helpers import ProgressIndicatorPercent, ProgressIndicatorEndless
|
||||
from ..helpers import load_exclude_file, load_pattern_file
|
||||
from ..helpers import CompressionDecider1
|
||||
from ..helpers import CompressionDecider
|
||||
from ..helpers import parse_pattern, PatternMatcher
|
||||
from ..helpers import PathFullPattern, PathPrefixPattern, FnmatchPattern, ShellPattern, RegexPattern
|
||||
from ..helpers import swidth_slice
|
||||
|
|
@ -1202,7 +1202,7 @@ data2
|
|||
assert list(clean_lines(conf, remove_comments=False)) == ['#comment', 'data1 #data1', 'data2', 'data3', ]
|
||||
|
||||
|
||||
def test_compression_decider1():
|
||||
def test_compression_decider():
|
||||
default = CompressionSpec('zlib')
|
||||
conf = """
|
||||
# use super-fast lz4 compression on huge VM files in this path:
|
||||
|
|
@ -1213,12 +1213,12 @@ none:*.jpeg
|
|||
none:*.zip
|
||||
""".splitlines()
|
||||
|
||||
cd = CompressionDecider1(default, []) # no conf, always use default
|
||||
cd = CompressionDecider(default, []) # no conf, always use default
|
||||
assert cd.decide('/srv/vm_disks/linux').name == 'zlib'
|
||||
assert cd.decide('test.zip').name == 'zlib'
|
||||
assert cd.decide('test').name == 'zlib'
|
||||
|
||||
cd = CompressionDecider1(default, [conf, ])
|
||||
cd = CompressionDecider(default, [conf, ])
|
||||
assert cd.decide('/srv/vm_disks/linux').name == 'lz4'
|
||||
assert cd.decide('test.zip').name == 'none'
|
||||
assert cd.decide('test').name == 'zlib' # no match in conf, use default
|
||||
|
|
|
|||
Loading…
Reference in a new issue