MCPcopy Create free account
hub / github.com/FastLED/FastLED / get_lock_database

Function get_lock_database

ci/util/lock_database.py:415–458  ·  view source on GitHub ↗

Resolve which DB file to use based on the lock path. - Paths under ~/.fastled/ or ~/.platformio/ -> ~/.fastled/locks.db - Everything else -> /.cache/locks.db Env override: FASTLED_LOCK_DB_PATH (for test isolation) Args: lock_path: Optional path hint for choos

(lock_path: Path | None = None)

Source from the content-addressed store, hash-verified

413
414
415def get_lock_database(lock_path: Path | None = None) -> LockDatabase:
416 """Resolve which DB file to use based on the lock path.
417
418 - Paths under ~/.fastled/ or ~/.platformio/ -> ~/.fastled/locks.db
419 - Everything else -> <project_root>/.cache/locks.db
420
421 Env override: FASTLED_LOCK_DB_PATH (for test isolation)
422
423 Args:
424 lock_path: Optional path hint for choosing DB location
425
426 Returns:
427 LockDatabase instance (cached per DB path)
428 """
429 # Check env override first
430 env_path = os.environ.get("FASTLED_LOCK_DB_PATH")
431 if env_path:
432 db_path_str = env_path
433 else:
434 home = Path.home()
435 fastled_dir = home / ".fastled"
436 platformio_dir = home / ".platformio"
437
438 use_global = False
439 if lock_path is not None:
440 try:
441 lock_str = str(lock_path.resolve())
442 if str(fastled_dir) in lock_str or str(platformio_dir) in lock_str:
443 use_global = True
444 except (OSError, ValueError):
445 pass
446
447 if use_global:
448 db_path = fastled_dir / "locks.db"
449 else:
450 project_root = Path(__file__).parent.parent.parent
451 db_path = project_root / ".cache" / "locks.db"
452
453 db_path_str = str(db_path)
454
455 if db_path_str not in _db_cache:
456 _db_cache[db_path_str] = LockDatabase(Path(db_path_str))
457
458 return _db_cache[db_path_str]

Callers 14

force_unlock_cacheFunction · 0.90
cleanup_stale_locksFunction · 0.90
list_active_locksFunction · 0.90
is_artifact_lockedFunction · 0.90
list_locksFunction · 0.90
clean_staleFunction · 0.90
force_unlock_allFunction · 0.90
check_lockFunction · 0.90
_read_lock_metadataFunction · 0.90
is_lock_staleFunction · 0.90

Calls 3

LockDatabaseClass · 0.85
getMethod · 0.45
resolveMethod · 0.45

Tested by 2