Skip to content

Commit

Permalink
create: catch StoreBackendAlreadyExists
Browse files Browse the repository at this point in the history
Don't show traceback if a repo at the given location already exists.
  • Loading branch information
ThomasWaldmann committed Oct 15, 2024
1 parent ffdc958 commit 703c98d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/borg/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from borgstore.store import ObjectNotFound as StoreObjectNotFound
from borgstore.backends.errors import BackendError as StoreBackendError
from borgstore.backends.errors import BackendDoesNotExist as StoreBackendDoesNotExist
from borgstore.backends.errors import BackendAlreadyExists as StoreBackendAlreadyExists

from .checksums import xxh64
from .constants import * # NOQA
Expand Down Expand Up @@ -117,6 +118,7 @@ def __init__(
url = "file://%s" % os.path.abspath(path_or_location)
location = Location(url)
self._location = location
self.url = url
# 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 = {
Expand Down Expand Up @@ -174,7 +176,10 @@ def id_str(self):

def create(self):
"""Create a new empty repository"""
self.store.create()
try:
self.store.create()
except StoreBackendAlreadyExists:
raise self.AlreadyExists(self.url)
self.store.open()
try:
self.store.store("config/readme", REPOSITORY_README.encode())
Expand Down

0 comments on commit 703c98d

Please sign in to comment.