From 0b7ec02b2f0e27549f272bb69dbe4d88df323e10 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Wed, 1 Jul 2026 23:03:25 +0200 Subject: [PATCH] chunkers: remove dead fill() error-return handling fill() is declared 'except 0' and always returns 1: errors propagate as exceptions, so the 'if not self.fill(): return None' branches were unreachable (and process() returning None would have crashed __next__ anyway). Call fill() plainly instead. Co-Authored-By: Claude Fable 5 --- src/borg/chunkers/buzhash.pyx | 6 ++---- src/borg/chunkers/buzhash64.pyx | 6 ++---- src/borg/chunkers/fastcdc.pyx | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/borg/chunkers/buzhash.pyx b/src/borg/chunkers/buzhash.pyx index 8a30594bc..4df5c629c 100644 --- a/src/borg/chunkers/buzhash.pyx +++ b/src/borg/chunkers/buzhash.pyx @@ -232,8 +232,7 @@ cdef class Chunker: raise Exception("chunkifier byte count mismatch") while self.remaining < min_size + window_size + 1 and not self.eof: # see assert in Chunker init - if not self.fill(): - return None + self.fill() # Here we either are at eof... if self.eof: @@ -268,8 +267,7 @@ cdef class Chunker: self.remaining -= did_bytes if self.remaining <= window_size: - if not self.fill(): - return None + self.fill() if self.remaining <= window_size: self.position += self.remaining diff --git a/src/borg/chunkers/buzhash64.pyx b/src/borg/chunkers/buzhash64.pyx index 1a1ce8fc9..d94cde483 100644 --- a/src/borg/chunkers/buzhash64.pyx +++ b/src/borg/chunkers/buzhash64.pyx @@ -237,8 +237,7 @@ cdef class ChunkerBuzHash64: raise Exception("chunkifier byte count mismatch") while self.remaining < min_size + window_size + 1 and not self.eof: # see assert in Chunker init - if not self.fill(): - return None + self.fill() # Here we either are at eof... if self.eof: @@ -294,8 +293,7 @@ cdef class ChunkerBuzHash64: self.remaining -= did_bytes if self.remaining <= window_size: - if not self.fill(): - return None + self.fill() if self.remaining <= window_size: self.position += self.remaining diff --git a/src/borg/chunkers/fastcdc.pyx b/src/borg/chunkers/fastcdc.pyx index 2248ff540..69d4b6d9c 100644 --- a/src/borg/chunkers/fastcdc.pyx +++ b/src/borg/chunkers/fastcdc.pyx @@ -175,8 +175,7 @@ cdef class ChunkerFastCDC: # ensure at least min_size + 1 bytes are buffered, or we are at eof while self.remaining < min_size + 1 and not self.eof: - if not self.fill(): - return None + self.fill() # at eof with only a remainder (< min_size + 1): emit it as the final chunk if self.eof and self.remaining < min_size + 1: @@ -207,8 +206,7 @@ cdef class ChunkerFastCDC: if self.remaining == 0: if self.eof: break # cut at end of data - if not self.fill(): - return None + self.fill() if self.remaining == 0: break # buffer full -> chunk reached max_size -> forced cut continue