mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-08-29 17:36:07 +00:00
fix sqlite cache path on Windows (#2250)
This commit is contained in:
+3
-2
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user