diff --git a/src/borg/archive.py b/src/borg/archive.py index 00a0867d0..90013bd29 100644 --- a/src/borg/archive.py +++ b/src/borg/archive.py @@ -19,7 +19,7 @@ from .logger import create_logger logger = create_logger() from . import xattr -from .chunker import get_chunker, Chunk, cached_hash, zeros +from .chunker import get_chunker, Chunk, cached_hash from .cache import ChunkListEntry from .crypto.key import key_factory from .compress import Compressor, CompressionSpec diff --git a/src/borg/chunker.pyx b/src/borg/chunker.pyx index 7f763ff24..099532308 100644 --- a/src/borg/chunker.pyx +++ b/src/borg/chunker.pyx @@ -6,7 +6,7 @@ import errno import os from collections import namedtuple -from .constants import CH_DATA, CH_ALLOC, CH_HOLE, MAX_DATA_SIZE +from .constants import CH_DATA, CH_ALLOC, CH_HOLE, MAX_DATA_SIZE, zeros from .lrucache import LRUCache from libc.stdlib cimport free @@ -53,8 +53,6 @@ def Chunk(data, **meta): return _Chunk(meta, data) -zeros = bytes(MAX_DATA_SIZE) - # remember a few recently used all-zero chunk hashes in this mapping. # (hash_func, chunk_length) -> chunk_hash # we play safe and have the hash_func in the mapping key, in case we diff --git a/src/borg/constants.py b/src/borg/constants.py index 46c2b564c..1bd9bb6dd 100644 --- a/src/borg/constants.py +++ b/src/borg/constants.py @@ -45,6 +45,10 @@ assert MAX_OBJECT_SIZE == 20 * 1024 * 1024 # repo config max_segment_size value must be below this limit to stay within uint32 offsets: MAX_SEGMENT_SIZE_LIMIT = 2 ** 32 - MAX_OBJECT_SIZE +# have one all-zero bytes object +# we use it at all places where we need to detect or create all-zero buffers +zeros = bytes(MAX_DATA_SIZE) + # borg.remote read() buffer size BUFSIZE = 10 * 1024 * 1024