1212class CacheManager :
1313 """Manages local caching of GitHub data using SQLite."""
1414
15- CACHE_DIR = Path .home () / ".config " / "gitfetch"
15+ CACHE_DIR = Path .home () / ".local" / "share " / "gitfetch"
1616 DB_FILE = CACHE_DIR / "cache.db"
1717
1818 def __init__ (self , cache_expiry_hours : int = 6 ):
@@ -29,6 +29,30 @@ def __init__(self, cache_expiry_hours: int = 6):
2929 def _ensure_cache_dir (self ) -> None :
3030 """Ensure cache directory exists."""
3131 self .CACHE_DIR .mkdir (parents = True , exist_ok = True )
32+ self ._migrate_old_cache ()
33+
34+ def _migrate_old_cache (self ) -> None :
35+ """Migrate cache from old locations to new."""
36+ old_locations = [
37+ Path .home () / ".config" / "gitfetch" ,
38+ Path .home () / ".cache" / "gitfetch"
39+ ]
40+ new_db_file = self .DB_FILE
41+
42+ for old_cache_dir in old_locations :
43+ old_db_file = old_cache_dir / "cache.db"
44+ if old_db_file .exists () and not new_db_file .exists ():
45+ try :
46+ # Copy the old database to the new location
47+ import shutil
48+ new_db_file .parent .mkdir (parents = True , exist_ok = True )
49+ shutil .copy2 (old_db_file , new_db_file )
50+ print (f"Cache migrated from { old_db_file } to "
51+ f"{ new_db_file } " )
52+ break # Only migrate from the first found location
53+ except Exception :
54+ # If migration fails, just continue
55+ pass
3256
3357 def _init_database (self ) -> None :
3458 """Initialize SQLite database with required tables."""
0 commit comments