Create a new empty repository
(self)
| 201 | return bin_to_hex(self.id) |
| 202 | |
| 203 | def create(self): |
| 204 | """Create a new empty repository""" |
| 205 | try: |
| 206 | self.store.create() |
| 207 | except StoreBackendAlreadyExists: |
| 208 | raise self.AlreadyExists(self.url) |
| 209 | self.store.open() |
| 210 | try: |
| 211 | self.store.store("config/readme", REPOSITORY_README.encode()) |
| 212 | self.version = 3 |
| 213 | self.store.store("config/version", str(self.version).encode()) |
| 214 | self.store.store("config/id", bin_to_hex(os.urandom(32)).encode()) |
| 215 | # we know repo/data/ still does not have any chunks stored in it, |
| 216 | # but for some stores, there might be a lot of empty directories and |
| 217 | # listing them all might be rather slow, so we better cache an empty |
| 218 | # ChunkIndex from here so that the first repo operation does not have |
| 219 | # to build the ChunkIndex the slow way by listing all the directories. |
| 220 | from borg.cache import write_chunkindex_to_repo_cache |
| 221 | |
| 222 | write_chunkindex_to_repo_cache(self, ChunkIndex(), clear=True, force_write=True) |
| 223 | finally: |
| 224 | self.store.close() |
| 225 | |
| 226 | def _set_id(self, id): |
| 227 | # for testing: change the id of an existing repository |
no test coverage detected