diff --git a/.gitignore b/.gitignore index dc501569b..26af5221f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ src/borg/compress.c src/borg/crypto/low_level.c src/borg/hashindex.c src/borg/item.c -src/borg/algorithms/chunker.c +src/borg/chunker.c src/borg/algorithms/checksums.c src/borg/platform/darwin.c src/borg/platform/freebsd.c diff --git a/setup.py b/setup.py index 434145032..d7746e4dc 100644 --- a/setup.py +++ b/setup.py @@ -52,7 +52,7 @@ compress_source = 'src/borg/compress.pyx' crypto_ll_source = 'src/borg/crypto/low_level.pyx' -chunker_source = 'src/borg/algorithms/chunker.pyx' +chunker_source = 'src/borg/chunker.pyx' hashindex_source = 'src/borg/hashindex.pyx' item_source = 'src/borg/item.pyx' checksums_source = 'src/borg/algorithms/checksums.pyx' @@ -89,7 +89,7 @@ def make_distribution(self): self.filelist.extend([ 'src/borg/compress.c', 'src/borg/crypto/low_level.c', - 'src/borg/algorithms/chunker.c', 'src/borg/algorithms/buzhash.c', + 'src/borg/chunker.c', 'src/borg/_chunker.c', 'src/borg/hashindex.c', 'src/borg/_hashindex.c', 'src/borg/item.c', 'src/borg/algorithms/checksums.c', @@ -623,8 +623,9 @@ def run(self): Extension('borg.crypto.low_level', [crypto_ll_source], libraries=crypto_libraries, include_dirs=include_dirs, library_dirs=library_dirs, define_macros=define_macros), Extension('borg.hashindex', [hashindex_source]), Extension('borg.item', [item_source]), - Extension('borg.algorithms.chunker', [chunker_source]), + Extension('borg.chunker', [chunker_source]), Extension('borg.algorithms.checksums', [checksums_source]), + ] if not sys.platform.startswith(('win32', )): ext_modules.append(Extension('borg.platform.posix', [platform_posix_source])) diff --git a/src/borg/algorithms/buzhash.c b/src/borg/_chunker.c similarity index 100% rename from src/borg/algorithms/buzhash.c rename to src/borg/_chunker.c diff --git a/src/borg/algorithms/__init__.py b/src/borg/algorithms/__init__.py index e69de29bb..cfa46c519 100644 --- a/src/borg/algorithms/__init__.py +++ b/src/borg/algorithms/__init__.py @@ -0,0 +1,11 @@ +""" +borg.algorithms +=============== + +This package is intended for hash and checksum functions. + +Ideally these would be sourced from existing libraries, +but are frequently not available yet (blake2), are +available but in poor form (crc32) or don't really +make sense as a library (xxHash). +""" diff --git a/src/borg/archive.py b/src/borg/archive.py index fb680d9bc..1c0b4b3f3 100644 --- a/src/borg/archive.py +++ b/src/borg/archive.py @@ -20,7 +20,7 @@ logger = create_logger() from . import xattr -from .algorithms.chunker import Chunker +from .chunker import Chunker from .cache import ChunkListEntry from .crypto.key import key_factory from .compress import Compressor, CompressionSpec diff --git a/src/borg/algorithms/chunker.pyx b/src/borg/chunker.pyx similarity index 98% rename from src/borg/algorithms/chunker.pyx rename to src/borg/chunker.pyx index efe87a495..bbe47ceca 100644 --- a/src/borg/algorithms/chunker.pyx +++ b/src/borg/chunker.pyx @@ -4,7 +4,7 @@ API_VERSION = '1.1_01' from libc.stdlib cimport free -cdef extern from "buzhash.c": +cdef extern from "_chunker.c": ctypedef int uint32_t ctypedef struct _Chunker "Chunker": pass diff --git a/src/borg/helpers.py b/src/borg/helpers.py index 1e79f63aa..62d0f5bab 100644 --- a/src/borg/helpers.py +++ b/src/borg/helpers.py @@ -1,11 +1,11 @@ import argparse -import collections import contextlib +import collections import grp import hashlib +import logging import io import json -import logging import os import os.path import platform @@ -27,21 +27,20 @@ from functools import partial, lru_cache from itertools import islice from operator import attrgetter -from shutil import get_terminal_size from string import Formatter +from shutil import get_terminal_size import msgpack import msgpack.fallback from .logger import create_logger - logger = create_logger() import borg.crypto.low_level from . import __version__ as borg_version from . import __version_tuple__ as borg_version_tuple +from . import chunker from . import hashindex -from .algorithms import chunker from .constants import * # NOQA diff --git a/src/borg/testsuite/chunker.py b/src/borg/testsuite/chunker.py index d18c4d0b3..2a14bd604 100644 --- a/src/borg/testsuite/chunker.py +++ b/src/borg/testsuite/chunker.py @@ -1,6 +1,6 @@ from io import BytesIO -from ..algorithms.chunker import Chunker, buzhash, buzhash_update +from ..chunker import Chunker, buzhash, buzhash_update from ..constants import * # NOQA from . import BaseTestCase