Skip to content

Commit 78171be

Browse files
committed
cahce cannot be set to 0
1 parent 0e8f5c4 commit 78171be

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/gitfetch/config.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,14 @@ def get_cache_expiry_minutes(self) -> int:
153153
Get cache expiry time in minutes.
154154
155155
Returns:
156-
Number of minutes before cache expires
156+
Number of minutes before cache expires (minimum 1)
157157
"""
158158
minutes_str = self.config.get(
159159
'DEFAULT', 'cache_expiry_minutes', fallback='15')
160160
try:
161-
return int(minutes_str)
161+
minutes = int(minutes_str)
162+
# Ensure cache expiry is at least 1 minute
163+
return max(1, minutes)
162164
except ValueError:
163165
return 15
164166

@@ -167,8 +169,11 @@ def set_cache_expiry_minutes(self, minutes: int) -> None:
167169
Set cache expiry time in minutes.
168170
169171
Args:
170-
minutes: Number of minutes before cache expires
172+
minutes: Number of minutes before cache expires (minimum 1)
171173
"""
174+
# Ensure cache expiry is at least 1 minute
175+
minutes = max(1, minutes)
176+
172177
if 'DEFAULT' not in self.config:
173178
self.config['DEFAULT'] = {}
174179
self.config['DEFAULT']['cache_expiry_minutes'] = str(minutes)

0 commit comments

Comments
 (0)