move zeros to constants module

This commit is contained in:
Thomas Waldmann 2021-01-14 20:02:18 +01:00
parent 3b9798cffc
commit be257728ca
3 changed files with 6 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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