Sfoglia il codice sorgente

Merge pull request #8875 from ThomasWaldmann/backports-1.4

Backports to 1.4-maint
TW 2 settimane fa
parent
commit
6799b8756b
5 ha cambiato i file con 33 aggiunte e 37 eliminazioni
  1. 11 15
      docs/development.rst
  2. 1 1
      setup.py
  3. 14 13
      src/borg/compress.pyx
  4. 1 0
      src/borg/testsuite/archiver.py
  5. 6 8
      tox.ini

+ 11 - 15
docs/development.rst

@@ -53,7 +53,7 @@ requests (if you don't have GitHub or don't want to use it you can
 send smaller patches via the borgbackup mailing list to the maintainers).
 send smaller patches via the borgbackup mailing list to the maintainers).
 
 
 Stable releases are maintained on maintenance branches named ``x.y-maint``, eg.
 Stable releases are maintained on maintenance branches named ``x.y-maint``, eg.
-the maintenance branch of the 1.0.x series is ``1.0-maint``.
+the maintenance branch of the 1.4.x series is ``1.4-maint``.
 
 
 Most PRs should be filed against the ``master`` branch. Only if an
 Most PRs should be filed against the ``master`` branch. Only if an
 issue affects **only** a particular maintenance branch a PR should be
 issue affects **only** a particular maintenance branch a PR should be
@@ -167,7 +167,6 @@ will have to be installed separately. Run this command to install the pre-commit
 
 
   pre-commit install
   pre-commit install
 
 
-
 Running the tests
 Running the tests
 -----------------
 -----------------
 
 
@@ -175,7 +174,7 @@ The tests are in the borg/testsuite package.
 
 
 To run all the tests, you need to have fakeroot installed. If you do not have
 To run all the tests, you need to have fakeroot installed. If you do not have
 fakeroot, you still will be able to run most tests, just leave away the
 fakeroot, you still will be able to run most tests, just leave away the
-`fakeroot -u` from the given command lines.
+``fakeroot -u`` from the given command lines.
 
 
 To run the test suite use the following command::
 To run the test suite use the following command::
 
 
@@ -198,13 +197,13 @@ Important notes:
 
 
 - When using ``--`` to give options to py.test, you MUST also give ``borg.testsuite[.module]``.
 - When using ``--`` to give options to py.test, you MUST also give ``borg.testsuite[.module]``.
 
 
-
 Running the tests (using the pypi package)
 Running the tests (using the pypi package)
 ------------------------------------------
 ------------------------------------------
 
 
 Since borg 1.4, it is also possible to run the tests without a development
 Since borg 1.4, it is also possible to run the tests without a development
 environment, using the borgbackup dist package (downloaded from pypi.org or
 environment, using the borgbackup dist package (downloaded from pypi.org or
-github releases page)::
+github releases page):
+::
 
 
     # optional: create and use a virtual env:
     # optional: create and use a virtual env:
     python3 -m venv env
     python3 -m venv env
@@ -229,7 +228,6 @@ github releases page)::
 
 
     pytest -rs --benchmark-skip -o 'python_files=testsuite/*.py' -o 'markers=allow_cache_wipe' --pyargs borg.testsuite
     pytest -rs --benchmark-skip -o 'python_files=testsuite/*.py' -o 'markers=allow_cache_wipe' --pyargs borg.testsuite
 
 
-
 Adding a compression algorithm
 Adding a compression algorithm
 ------------------------------
 ------------------------------
 
 
@@ -306,7 +304,6 @@ Usage::
    # To copy files from the VM (in this case, the generated binary):
    # To copy files from the VM (in this case, the generated binary):
    vagrant scp OS:/vagrant/borg/borg.exe .
    vagrant scp OS:/vagrant/borg/borg.exe .
 
 
-
 Creating standalone binaries
 Creating standalone binaries
 ----------------------------
 ----------------------------
 
 
@@ -325,7 +322,6 @@ If you encounter issues, see also our `Vagrantfile` for details.
           work on same OS, same architecture (x86 32bit, amd64 64bit)
           work on same OS, same architecture (x86 32bit, amd64 64bit)
           without external dependencies.
           without external dependencies.
 
 
-
 .. _releasing:
 .. _releasing:
 
 
 Creating a new release
 Creating a new release
@@ -382,16 +378,16 @@ Checklist:
   new version number and release date.
   new version number and release date.
 - Announce on:
 - Announce on:
 
 
- - Mailing list.
- - Twitter.
- - IRC channel (change ``/topic``).
+  - Mailing list.
+  - Mastodon / BlueSky / X (aka Twitter).
+  - IRC channel (change ``/topic``).
 
 
 - Create a GitHub release, include:
 - Create a GitHub release, include:
 
 
-  * pypi dist package and signature
-  * Standalone binaries (see above for how to create them).
+  - pypi dist package and signature
+  - Standalone binaries (see above for how to create them).
 
 
-    + For macOS, document the macFUSE version in the README of the binaries.
+    - For macOS, document the macFUSE version in the README of the binaries.
       macFUSE uses a kernel extension that needs to be compatible with the
       macFUSE uses a kernel extension that needs to be compatible with the
       code contained in the binary.
       code contained in the binary.
-  * A link to ``CHANGES.rst``.
+  - A link to ``CHANGES.rst``.

+ 1 - 1
setup.py

@@ -44,7 +44,7 @@ cpu_threads = multiprocessing.cpu_count() if multiprocessing and multiprocessing
 on_rtd = os.environ.get("READTHEDOCS")
 on_rtd = os.environ.get("READTHEDOCS")
 
 
 # Extra cflags for all extensions, usually just warnings we want to enable explicitly
 # Extra cflags for all extensions, usually just warnings we want to enable explicitly
-cflags = ["-Wall", "-Wextra", "-Wpointer-arith"]
+cflags = ["-Wall", "-Wextra", "-Wpointer-arith", "-Wno-unreachable-code-fallthrough"]
 
 
 compress_source = "src/borg/compress.pyx"
 compress_source = "src/borg/compress.pyx"
 crypto_ll_source = "src/borg/crypto/low_level.pyx"
 crypto_ll_source = "src/borg/crypto/low_level.pyx"

+ 14 - 13
src/borg/compress.pyx

@@ -465,7 +465,7 @@ class ObfuscateSize(CompressorBase):
     def _obfuscate(self, compr_size):
     def _obfuscate(self, compr_size):
         # implementations need to return the size of obfuscation data,
         # implementations need to return the size of obfuscation data,
         # that the caller shall add.
         # that the caller shall add.
-        raise NotImplemented
+        raise NotImplementedError
 
 
     def _relative_random_reciprocal_obfuscate(self, compr_size):
     def _relative_random_reciprocal_obfuscate(self, compr_size):
         # effect for SPEC 1:
         # effect for SPEC 1:
@@ -480,6 +480,19 @@ class ObfuscateSize(CompressorBase):
     def _random_padding_obfuscate(self, compr_size):
     def _random_padding_obfuscate(self, compr_size):
         return int(self.max_padding_size * random.random())
         return int(self.max_padding_size * random.random())
 
 
+    def _padme_obfuscate(self, compr_size):
+        if compr_size < 2:
+            return 0
+
+        E = math.floor(math.log2(compr_size))  # Get exponent (power of 2)
+        S = math.floor(math.log2(E)) + 1       # Second log component
+        lastBits = E - S                       # Bits to be zeroed
+        bitMask = (2 ** lastBits - 1)          # Mask for rounding
+
+        padded_size = (compr_size + bitMask) & ~bitMask  # Apply rounding
+
+        return padded_size - compr_size  # Return only the additional padding size
+
     def compress(self, data):
     def compress(self, data):
         compressed_data = self.compressor.compress(data)  # compress data
         compressed_data = self.compressor.compress(data)  # compress data
         compr_size = len(compressed_data)
         compr_size = len(compressed_data)
@@ -501,18 +514,6 @@ class ObfuscateSize(CompressorBase):
             self.compressor = Compressor.detect(compressed_data)()
             self.compressor = Compressor.detect(compressed_data)()
         return self.compressor.decompress(compressed_data)  # decompress data
         return self.compressor.decompress(compressed_data)  # decompress data
 
 
-    def _padme_obfuscate(self, compr_size):
-        if compr_size < 2:
-            return 0
-
-        E = math.floor(math.log2(compr_size))  # Get exponent (power of 2)
-        S = math.floor(math.log2(E)) + 1       # Second log component
-        lastBits = E - S                       # Bits to be zeroed
-        bitMask = (2 ** lastBits - 1)          # Mask for rounding
-
-        padded_size = (compr_size + bitMask) & ~bitMask  # Apply rounding
-
-        return padded_size - compr_size  # Return only the additional padding size
 
 
 # Maps valid compressor names to their class
 # Maps valid compressor names to their class
 COMPRESSOR_TABLE = {
 COMPRESSOR_TABLE = {

+ 1 - 0
src/borg/testsuite/archiver.py

@@ -4585,6 +4585,7 @@ class DiffArchiverTestCase(ArchiverTestCaseBase):
         self.create_regular_file('file_replaced', contents=b'0' * 4096)
         self.create_regular_file('file_replaced', contents=b'0' * 4096)
         os.unlink('input/file_removed')
         os.unlink('input/file_removed')
         os.unlink('input/file_removed2')
         os.unlink('input/file_removed2')
+        time.sleep(1)  # macOS HFS+ has a 1s timestamp granularity
         Path('input/file_touched').touch()
         Path('input/file_touched').touch()
         os.rmdir('input/dir_replaced_with_file')
         os.rmdir('input/dir_replaced_with_file')
         self.create_regular_file('dir_replaced_with_file', size=8192)
         self.create_regular_file('dir_replaced_with_file', size=8192)

+ 6 - 8
tox.ini

@@ -4,10 +4,11 @@
 [tox]
 [tox]
 envlist = py{39,310,311,312,313}-{none,fuse2,fuse3}
 envlist = py{39,310,311,312,313}-{none,fuse2,fuse3}
 requires =
 requires =
-	pkgconfig
-	cython
-	wheel
-	setuptools_scm
+    pkgconfig
+    cython
+    wheel
+    setuptools_scm
+
 [testenv]
 [testenv]
 setenv =
 setenv =
    fuse2: BORG_FUSE_IMPL=llfuse
    fuse2: BORG_FUSE_IMPL=llfuse
@@ -16,19 +17,16 @@ deps =
     fuse2: llfuse
     fuse2: llfuse
     fuse3: pyfuse3
     fuse3: pyfuse3
     -rrequirements.d/development.txt
     -rrequirements.d/development.txt
-commands = py.test -v -n {env:XDISTN:1} -rs --cov=borg --cov-config=.coveragerc --benchmark-skip --pyargs {posargs:borg.testsuite}
+commands = pytest -v -n {env:XDISTN:1} -rs --cov=borg --cov-config=.coveragerc --benchmark-skip --pyargs {posargs:borg.testsuite}
 # fakeroot -u needs some env vars:
 # fakeroot -u needs some env vars:
 passenv = *
 passenv = *
 
 
-
 [testenv:.pkg]
 [testenv:.pkg]
 passenv = *  # needed by tox4, so env vars are visible for building borg
 passenv = *  # needed by tox4, so env vars are visible for building borg
 
 
-
 [testenv:ruff]
 [testenv:ruff]
 skip_sdist=true
 skip_sdist=true
 skip_install=true
 skip_install=true
-changedir =
 deps =
 deps =
     ruff
     ruff
 commands = ruff check .
 commands = ruff check .