Skip to content

Commit

Permalink
chore(cache): do not create cache file until we need it
Browse files Browse the repository at this point in the history
This is required to be able to skip caching for some commands.
  • Loading branch information
agateau-gg authored and Jguer committed Oct 4, 2021
1 parent 86c47dd commit 291af0b
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions ggshield/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,8 @@ def __setattr__(self, name: str, value: Any) -> None:
else:
super().__setattr__(name, value)

def create_empty_cache(self) -> None:
# Creates a new file
try:
with open(self.CACHE_FILENAME, "w"):
pass
except PermissionError:
# Hotfix: for the time being we skip cache handling if permission denied
pass

def load_cache(self) -> bool:
if not os.path.isfile(self.CACHE_FILENAME):
self.create_empty_cache()
return True

_cache: dict = {}
Expand Down Expand Up @@ -286,9 +276,6 @@ def to_dict(self) -> Dict[str, Any]:
return _cache

def save(self) -> bool:
if not os.path.isfile(self.CACHE_FILENAME):
return False

try:
f = open(self.CACHE_FILENAME, "w")
except PermissionError:
Expand Down

0 comments on commit 291af0b

Please sign in to comment.