Skip to content

Store.gather / Store.defrag: limit them to items of the given namespace - #232

Merged
ThomasWaldmann merged 1 commit into
borgbackup:mainfrom
ThomasWaldmann:same-namespace
Sep 26, 2026
Merged

ThomasWaldmann merged 1 commit into
borgbackup:mainfrom
ThomasWaldmann:same-namespace

Conversation

@ThomasWaldmann

Copy link
Copy Markdown
Member

Follow-up to #231.

Store.gather and Store.defrag now require all items (and the defrag target) to be in the given namespace: item names are given without the namespace, and a / in an item name raises ValueError. A name with a / could address an item in a deeper namespace (e.g. sub/x in namespace data belongs to data/sub/ if that is configured), with other nesting levels and another cache policy.

This simplifies Store.gather: all ranges are in one namespace, so they all have the same cache policy. gather now either reads all ranges via the cache path (writethrough / mirror namespace) or gathers all of them from the backend with one call. The per-range cache policy lookup and the merging of cached and backend ranges are gone.

  • _find_sources: shared by gather and defrag - validates the sources, rejects / in item names, maps the names to nested backend names (one find per distinct name).
  • The backend-level gather / defrag are unchanged (they get full backend names).
  • borg is not affected: it calls defrag with namespace="packs" and plain hex names.
  • Tests: new test for the namespace rule (gather, defrag sources and target); the one cache test that mixed namespaces in a single gather call is removed.
  • Docs + changelog.

🤖 Generated with Claude Code

All items (and the defrag target) must be in the given namespace: item names are
given without the namespace and a "/" in an item name now raises ValueError. Such a
name could address an item in a deeper namespace, with other nesting levels and
another cache policy.

As all ranges are in one namespace, they all have the same cache policy, so gather
either reads all ranges via the cache path or gathers all of them from the backend
with one call. This removes the per-range policy lookup and the merging of cached and
backend ranges.

gather and defrag share the validation and name mapping code (_find_sources).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ThomasWaldmann
ThomasWaldmann merged commit 11cbc5c into borgbackup:main Sep 26, 2026
9 checks passed
@ThomasWaldmann
ThomasWaldmann deleted the same-namespace branch September 26, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant