MCPcopy
hub / github.com/GitGuardian/ggshield / save

Method save

ggshield/core/cache.py:59–77  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

57 }
58
59 def save(self) -> None:
60 if not self.last_found_secrets:
61 # if there are no found secrets, don't modify the cache file
62 return
63 try:
64 fd = os.open(
65 str(self.cache_path), os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600
66 )
67 f = os.fdopen(fd, "w")
68 except OSError:
69 # Hotfix: for the time being we skip cache handling if permission denied
70 return
71 with f:
72 try:
73 json.dump(self.to_dict(), f)
74 except Exception as e:
75 raise UnexpectedError(
76 f"Failed to save cache in {self.cache_path}:\n{str(e)}"
77 )
78
79 def purge(self) -> None:
80 self.last_found_secrets = []

Callers 15

test_save_cacheMethod · 0.95
test_read_only_fsMethod · 0.95
_install_from_urlFunction · 0.45
enable_cmdFunction · 0.45
disable_cmdFunction · 0.45
uninstall_cmdFunction · 0.45
update_cmdFunction · 0.45

Calls 3

to_dictMethod · 0.95
UnexpectedErrorClass · 0.90
openMethod · 0.80