Skip to content

Commit

Permalink
Merge pull request #8434 from ThomasWaldmann/levels-config-for-borgstore
Browse files Browse the repository at this point in the history
give borgstore.Store a complete levels configuration, fixes #8432
  • Loading branch information
ThomasWaldmann authored Sep 28, 2024
2 parents 156d33e + 0d269e7 commit 069cbb4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/borg/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,18 @@ def __init__(
url = "file://%s" % os.path.abspath(path_or_location)
location = Location(url)
self._location = location
# use a Store with flat config storage and 2-levels-nested data storage
# lots of stuff in data: use 2 levels by default (data/00/00/ .. data/ff/ff/ dirs)!
data_levels = int(os.environ.get("BORG_STORE_DATA_LEVELS", "2"))
levels_config = {
"archives/": [0],
"cache/": [0],
"config/": [0],
"data/": [data_levels],
"keys/": [0],
"locks/": [0],
}
try:
self.store = Store(url, levels={"config/": [0], "data/": [2]})
self.store = Store(url, levels=levels_config)
except StoreBackendError as e:
raise Error(str(e))
self.version = None
Expand Down
1 change: 1 addition & 0 deletions src/borg/testsuite/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def clean_env(tmpdir_factory, monkeypatch):
monkeypatch.setenv("BORG_BASE_DIR", str(tmpdir_factory.mktemp("borg-base-dir")))
# Speed up tests
monkeypatch.setenv("BORG_TESTONLY_WEAKEN_KDF", "1")
monkeypatch.setenv("BORG_STORE_DATA_LEVELS", "0") # flat storage for few objects


def pytest_report_header(config, start_path):
Expand Down
2 changes: 1 addition & 1 deletion src/borg/testsuite/storelocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@pytest.fixture()
def lockstore(tmpdir):
store = Store("file://" + str(tmpdir / "lockstore"))
store = Store("file://" + str(tmpdir / "lockstore"), levels={"locks/": [0]})
store.create()
with store:
yield store
Expand Down

0 comments on commit 069cbb4

Please sign in to comment.