]> git.hungrycats.org Git - bees/commitdiff
scan-next: return early from the sweep-join source walk on an unopenable ref
authorZygo Blaxell <bees@furryterror.org>
Tue, 4 Aug 2026 17:47:22 +0000 (13:47 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sat, 10 Oct 2026 19:00:04 +0000 (15:00 -0400)
Invert the source open check into an early "keep walking" return, so the
path that builds the pair is no longer nested inside it.  No behaviour
change: the check already tests the Fd with !!, so an unopenable source
ref is skipped and the walk tries the other overlapping refs.

Assisted-by: Claude-Code:claude-fable-5
Assisted-by: Claude-Code:claude-opus-5-5
src/bees-scan-next.cc

index 02139ee2ef17db05032184b4da9c056b7b654abf..160a563f95d554ff13f18ff9ed7cded8b075c7b6 100644 (file)
@@ -854,24 +854,24 @@ scan_next_sweep_join_pairs(BeesContext &ctx,
                        const auto src_sub_slice = BeesExtentSlice(src_tree, cursor, dst_ref.end());
                        src_sub_slice.refs(ctx.layer().get(), [&](BeesExtentLayer *, const BeesTreeRefSlice &src_ref) {
                                const auto src_fd = src_ref.ref().open(ctx);
-                               if (!!src_fd) {
-                                       const auto overlap_end = min(src_ref.end(), dst_ref.end());
-                                       const auto src_file_begin = src_ref.file_begin() + cursor - src_ref.begin();
-                                       const auto src_file_end = src_file_begin + overlap_end - cursor;
-                                       const auto dst_file_begin = dst_ref.file_begin() + cursor - dst_ref.begin();
-                                       const auto dst_file_end = dst_file_begin + overlap_end - cursor;
-
-                                       if (const auto pair = scan_next_make_clipped_file_pair(
-                                                   src_fd, src_file_begin, src_file_end,
-                                                   dst_fd, dst_file_begin, dst_file_end)) {
-                                               append_pair(*pair);
-                                       }
-
-                                       best_overlap_end = max(best_overlap_end, overlap_end);
-                                       covered = true;
-                                       return false; // Stop walking once covered
+                               if (!src_fd) {
+                                       return true; // Keep walking to try other overlapping fallbacks
                                }
-                               return true; // Keep walking to try other overlapping fallbacks
+                               const auto overlap_end = min(src_ref.end(), dst_ref.end());
+                               const auto src_file_begin = src_ref.file_begin() + cursor - src_ref.begin();
+                               const auto src_file_end = src_file_begin + overlap_end - cursor;
+                               const auto dst_file_begin = dst_ref.file_begin() + cursor - dst_ref.begin();
+                               const auto dst_file_end = dst_file_begin + overlap_end - cursor;
+
+                               if (const auto pair = scan_next_make_clipped_file_pair(
+                                           src_fd, src_file_begin, src_file_end,
+                                           dst_fd, dst_file_begin, dst_file_end)) {
+                                       append_pair(*pair);
+                               }
+
+                               best_overlap_end = max(best_overlap_end, overlap_end);
+                               covered = true;
+                               return false; // Stop walking once covered
                        }, BeesVisitorPath::src);
 
                        if (!covered) {