remove the superfluous borg.checksums module

This commit is contained in:
Thomas Waldmann 2026-05-12 18:41:34 +02:00
parent ca3e88f5b1
commit 227484b679
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01
7 changed files with 2 additions and 38 deletions

View file

@ -561,7 +561,6 @@ src/borg/chunkers/buzhash64.pyx
src/borg/chunkers/reader.pyx
src/borg/hashindex.pyx
src/borg/item.pyx
src/borg/checksums.pyx
src/borg/platform/posix.pyx
src/borg/platform/linux.pyx
src/borg/platform/syncfilerange.pyx

View file

@ -55,7 +55,6 @@ buzhash64_source = "src/borg/chunkers/buzhash64.pyx"
reader_source = "src/borg/chunkers/reader.pyx"
hashindex_source = "src/borg/hashindex.pyx"
item_source = "src/borg/item.pyx"
checksums_source = "src/borg/checksums.pyx"
platform_posix_source = "src/borg/platform/posix.pyx"
platform_linux_source = "src/borg/platform/linux.pyx"
platform_syncfilerange_source = "src/borg/platform/syncfilerange.pyx"
@ -72,7 +71,6 @@ cython_sources = [
reader_source,
hashindex_source,
item_source,
checksums_source,
platform_posix_source,
platform_linux_source,
platform_syncfilerange_source,
@ -163,8 +161,6 @@ if not on_rtd:
dict(extra_compile_args=cflags),
)
checksums_ext_kwargs = members_appended(dict(sources=[checksums_source]), dict(extra_compile_args=cflags))
if sys.platform == "linux":
linux_ext_kwargs = members_appended(
dict(sources=[platform_linux_source]),
@ -184,7 +180,6 @@ if not on_rtd:
Extension("borg.chunkers.buzhash", [buzhash_source], extra_compile_args=cflags),
Extension("borg.chunkers.buzhash64", [buzhash64_source], extra_compile_args=cflags),
Extension("borg.chunkers.reader", [reader_source], extra_compile_args=cflags),
Extension("borg.checksums", **checksums_ext_kwargs),
]
posix_ext = Extension("borg.platform.posix", [platform_posix_source], extra_compile_args=cflags)

View file

@ -216,7 +216,7 @@ class BenchmarkMixIn:
print(f"{spec:<24} {format_file_size(size):<10} {dt:.3f}s")
from xxhash import xxh64
from ..checksums import crc32
from zlib import crc32
if not args.json:
print("Non-cryptographic checksums / hashes ===========================")

View file

@ -1 +0,0 @@
def crc32(data: bytes, value: int = 0) -> int: ...

View file

@ -1,6 +0,0 @@
import zlib
# Borg 2.0 repositories do not compute CRC32 over large amounts of data,
# so speed does not matter much anymore, and we can just use zlib.crc32.
crc32 = zlib.crc32

View file

@ -11,6 +11,7 @@ from configparser import ConfigParser
from functools import partial
from itertools import islice
from collections.abc import Callable
from zlib import crc32
import xxhash
@ -28,7 +29,6 @@ from ..logger import create_logger
from ..manifest import Manifest, NoManifestError
from ..platform import SaveFile, SyncFile, sync_dir, safe_fadvise
from ..repoobj import RepoObj
from ..checksums import crc32
from ..crypto.file_integrity import IntegrityCheckedFile, FileIntegrityError
logger = create_logger(__name__)

View file

@ -1,23 +0,0 @@
from xxhash import xxh64
from ..helpers import hex_to_bin
def test_xxh64():
assert xxh64(b"test", 123).hexdigest() == "2b81b9401bef86cf"
assert xxh64(b"test").hexdigest() == "4fdcca5ddb678139"
assert (
xxh64(
hex_to_bin(
"6f663f01c118abdea553373d5eae44e7dac3b6829b46b9bbeff202b6c592c22d724"
"fb3d25a347cca6c5b8f20d567e4bb04b9cfa85d17f691590f9a9d32e8ccc9102e9d"
"cf8a7e6716280cd642ce48d03fdf114c9f57c20d9472bb0f81c147645e6fa3d331"
)
).hexdigest()
== "35d5d2f545d9511a"
)
hasher = xxh64(seed=123)
hasher.update(b"te")
hasher.update(b"st")
assert hasher.hexdigest() == "2b81b9401bef86cf"