From efcaaae5b41bde57391d53d845017ffdd56d7075 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 30 Aug 2024 12:19:02 -0700 Subject: [PATCH] refactor: introduce global constant VERSION_CHECK_FNAME --- aider/versioncheck.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/aider/versioncheck.py b/aider/versioncheck.py index a63e44771..883fd82f1 100644 --- a/aider/versioncheck.py +++ b/aider/versioncheck.py @@ -9,6 +9,8 @@ import aider from aider import utils from aider.dump import dump # noqa: F401 +VERSION_CHECK_FNAME = Path.home() / ".aider" / "caches" / "versioncheck" + def install_from_main_branch(io): """ @@ -35,10 +37,9 @@ def install_upgrade(io): def check_version(io, just_check=False, verbose=False): - fname = Path.home() / ".aider" / "caches" / "versioncheck" - if not just_check and fname.exists(): + if not just_check and VERSION_CHECK_FNAME.exists(): day = 60 * 60 * 24 - since = time.time() - os.path.getmtime(fname) + since = time.time() - os.path.getmtime(VERSION_CHECK_FNAME) if 0 < since < day: if verbose: hours = since / 60 / 60 @@ -65,8 +66,8 @@ def check_version(io, just_check=False, verbose=False): io.tool_error(f"Error checking pypi for new version: {err}") return False finally: - fname.parent.mkdir(parents=True, exist_ok=True) - fname.touch() + VERSION_CHECK_FNAME.parent.mkdir(parents=True, exist_ok=True) + VERSION_CHECK_FNAME.touch() if just_check or verbose: if is_update_available: