fix sqlite cache path on Windows (#2250)

This commit is contained in:
2-5
2023-11-09 10:32:34 -08:00
committed by GitHub
parent 10d642e174
commit 50bf0703aa
+3 -2
View File
@@ -157,7 +157,7 @@ class GlobalCounters:
# *** universal database cache ***
_cache_dir: str = getenv("XDG_CACHE_HOME", os.path.expanduser("~/Library/Caches" if OSX else "~/.cache"))
CACHEDB: str = getenv("CACHEDB", os.path.join(_cache_dir, "tinygrad", "cache.db"))
CACHEDB: str = getenv("CACHEDB", os.path.abspath(os.path.join(_cache_dir, "tinygrad", "cache.db")))
CACHELEVEL = getenv("CACHELEVEL", 2)
VERSION = 6
@@ -165,11 +165,12 @@ _db_connection = None
def db_connection():
global _db_connection
if _db_connection is None:
os.makedirs(CACHEDB.rsplit("/", 1)[0], exist_ok=True)
os.makedirs(CACHEDB.rsplit(os.sep, 1)[0], exist_ok=True)
_db_connection = sqlite3.connect(CACHEDB)
if DEBUG >= 7: _db_connection.set_trace_callback(print)
if diskcache_get("meta", "version") != VERSION:
print("cache is out of date, clearing it")
_db_connection.close()
del _db_connection
os.unlink(CACHEDB)
_db_connection = sqlite3.connect(CACHEDB)