MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getIdeLockfilesPaths

Function getIdeLockfilesPaths

source code/utils/ide.ts:464–517  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

462 * stat loop compounded startup latency.
463 */
464export async function getIdeLockfilesPaths(): Promise<string[]> {
465 const paths: string[] = [join(getClaudeConfigHomeDir(), 'ide')]
466
467 if (getPlatform() !== 'wsl') {
468 return paths
469 }
470
471 // For Windows, use heuristics to find the potential paths.
472 // See https://learn.microsoft.com/en-us/windows/wsl/filesystems
473
474 const windowsHome = await getWindowsUserProfile()
475
476 if (windowsHome) {
477 const converter = new WindowsToWSLConverter(process.env.WSL_DISTRO_NAME)
478 const wslPath = converter.toLocalPath(windowsHome)
479 paths.push(resolve(wslPath, '.claude', 'ide'))
480 }
481
482 // Construct the path based on the standard Windows WSL locations
483 // This can fail if the current user does not have "List folder contents" permission on C:\Users
484 try {
485 const usersDir = '/mnt/c/Users'
486 const userDirs = await getFsImplementation().readdir(usersDir)
487
488 for (const user of userDirs) {
489 // Skip files (e.g. desktop.ini) — readdir on a file path throws ENOTDIR.
490 // isFsInaccessible covers ENOTDIR, but pre-filtering here avoids the
491 // cost of attempting to readdir non-directories. Symlinks are kept since
492 // Windows creates junction points for user profiles.
493 if (!user.isDirectory() && !user.isSymbolicLink()) {
494 continue
495 }
496 if (
497 user.name === 'Public' ||
498 user.name === 'Default' ||
499 user.name === 'Default User' ||
500 user.name === 'All Users'
501 ) {
502 continue // Skip system directories
503 }
504 paths.push(join(usersDir, user.name, '.claude', 'ide'))
505 }
506 } catch (error: unknown) {
507 if (isFsInaccessible(error)) {
508 // Expected on WSL when C: drive is not mounted or user lacks permissions
509 logForDebugging(
510 `WSL IDE lockfile path detection failed (${error.code}): ${errorMessage(error)}`,
511 )
512 } else {
513 logError(error)
514 }
515 }
516 return paths
517}
518
519/**
520 * Cleans up stale IDE lockfiles

Callers 1

getSortedIdeLockfilesFunction · 0.85

Calls 8

toLocalPathMethod · 0.95
getPlatformFunction · 0.85
getFsImplementationFunction · 0.85
isFsInaccessibleFunction · 0.85
logForDebuggingFunction · 0.85
resolveFunction · 0.70
errorMessageFunction · 0.70
logErrorFunction · 0.70

Tested by

no test coverage detected