MCPcopy
hub / github.com/borgbackup/borg / __init__

Method __init__

src/borg/repository.py:97–179  ·  view source on GitHub ↗
(
        self,
        path_or_location,
        create=False,
        exclusive=False,
        lock_wait=1.0,
        lock=True,
        send_log_cb=None,
        permissions=None,
    )

Source from the content-addressed store, hash-verified

95 exit_mcode = 21
96
97 def __init__(
98 self,
99 path_or_location,
100 create=False,
101 exclusive=False,
102 lock_wait=1.0,
103 lock=True,
104 send_log_cb=None,
105 permissions=None,
106 ):
107 if isinstance(path_or_location, Location):
108 location = path_or_location
109 if location.proto == "file":
110 url = Path(location.path).as_uri()
111 else:
112 url = location.processed # location as given by user, processed placeholders
113 else:
114 url = Path(path_or_location).absolute().as_uri()
115 location = Location(url)
116 self._location = location
117 self.url = url
118 # lots of stuff in data: use 2 levels by default (data/00/00/ .. data/ff/ff/ dirs)!
119 data_levels = int(os.environ.get("BORG_STORE_DATA_LEVELS", "2"))
120 levels_config = {
121 "archives/": [0],
122 "cache/": [0],
123 "config/": [0],
124 "data/": [data_levels],
125 "keys/": [0],
126 "locks/": [0],
127 }
128 # Get permissions from parameter or environment variable
129 permissions = permissions if permissions is not None else os.environ.get("BORG_REPO_PERMISSIONS", "all")
130
131 if permissions == "all":
132 permissions = None # permissions system will not be used
133 elif permissions == "no-delete": # mostly no delete, no overwrite
134 permissions = {
135 "": "lr",
136 "archives": "lrw",
137 "cache": "lrwWD", # WD for chunks.<HASH>, last-key-checked, ...
138 "config": "lrW", # W for manifest
139 "data": "lrw",
140 "keys": "lr",
141 "locks": "lrwD", # borg needs to create/delete a shared lock here
142 }
143 elif permissions == "write-only": # mostly no reading
144 permissions = {
145 "": "l",
146 "archives": "lw",
147 "cache": "lrwWD", # read allowed, e.g. for chunks.<HASH> cache
148 "config": "lrW", # W for manifest
149 "data": "lw", # no r!
150 "keys": "lr",
151 "locks": "lrwD", # borg needs to create/delete a shared lock here
152 }
153 elif permissions == "read-only": # mostly r/o
154 permissions = {"": "lr", "locks": "lrwD"}

Callers 1

__init__Method · 0.45

Calls 3

LocationClass · 0.85
ErrorClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected