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

Method load

src/borg/fslocking.py:291–315  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

289 self.kill_stale_locks = True
290
291 def load(self):
292 try:
293 with self.path.open() as f:
294 data = json.load(f)
295
296 # Just nuke the stale locks early on load
297 if self.kill_stale_locks:
298 for key in (SHARED, EXCLUSIVE):
299 try:
300 entries = data[key]
301 except KeyError:
302 continue
303 elements = set()
304 for host, pid, thread in entries:
305 if platform.process_alive(host, pid, thread):
306 elements.add((host, pid, thread))
307 else:
308 logger.warning(
309 "Removed stale %s roster lock for host %s pid %d thread %d.", key, host, pid, thread
310 )
311 data[key] = list(elements)
312 except (FileNotFoundError, ValueError):
313 # no or corrupt/empty roster file?
314 data = {}
315 return data
316
317 def save(self, data):
318 with self.path.open("w") as f:

Callers 3

getMethod · 0.95
modifyMethod · 0.95
test_emptyMethod · 0.95

Calls 3

warningMethod · 0.80
openMethod · 0.45
addMethod · 0.45

Tested by 1

test_emptyMethod · 0.76