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

Method assert_location_matches

src/borg/cache.py:135–167  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

133 fd.write(manifest.timestamp)
134
135 def assert_location_matches(self):
136 # Warn user before sending data to a relocated repository
137 try:
138 with self.location_file.open() as fd:
139 previous_location = fd.read()
140 logger.debug("security: read previous location %r", previous_location)
141 except FileNotFoundError:
142 logger.debug("security: previous location file %s not found", self.location_file)
143 previous_location = None
144 except OSError as exc:
145 logger.warning("Could not read previous location file: %s", exc)
146 previous_location = None
147
148 repository_location = self.repository._location.canonical_path()
149 if previous_location and previous_location != repository_location:
150 msg = (
151 "Warning: The repository at location {} was previously located at {}\n".format(
152 repository_location, previous_location
153 )
154 + "Do you want to continue? [yN] "
155 )
156 if not yes(
157 msg,
158 false_msg="Aborting.",
159 invalid_msg="Invalid answer, aborting.",
160 retry=False,
161 env_var_override="BORG_RELOCATED_REPO_ACCESS_IS_OK",
162 ):
163 raise Cache.RepositoryAccessAborted()
164 # adapt on-disk config immediately if the new location was accepted
165 logger.debug("security: updating location stored in security dir")
166 with SaveFile(self.location_file) as fd:
167 fd.write(repository_location)
168
169 def assert_no_manifest_replay(self, manifest, key):
170 try:

Callers 1

_assert_secureMethod · 0.95

Calls 9

yesFunction · 0.90
SaveFileClass · 0.85
debugMethod · 0.80
warningMethod · 0.80
openMethod · 0.45
readMethod · 0.45
canonical_pathMethod · 0.45
formatMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected