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

Function getSortedIdeLockfiles

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

Source from the content-addressed store, hash-verified

298 * @returns Array of full lockfile paths sorted by modification time (newest first)
299 */
300export async function getSortedIdeLockfiles(): Promise<string[]> {
301 try {
302 const ideLockFilePaths = await getIdeLockfilesPaths()
303
304 // Collect all lockfiles from all directories
305 const allLockfiles: Array<{ path: string; mtime: Date }>[] =
306 await Promise.all(
307 ideLockFilePaths.map(async ideLockFilePath => {
308 try {
309 const entries = await getFsImplementation().readdir(ideLockFilePath)
310 const lockEntries = entries.filter(file =>
311 file.name.endsWith('.lock'),
312 )
313 // Stat all lockfiles in parallel; skip ones that fail
314 const stats = await Promise.all(
315 lockEntries.map(async file => {
316 const fullPath = join(ideLockFilePath, file.name)
317 try {
318 const fileStat = await getFsImplementation().stat(fullPath)
319 return { path: fullPath, mtime: fileStat.mtime }
320 } catch {
321 return null
322 }
323 }),
324 )
325 return stats.filter(s => s !== null)
326 } catch (error) {
327 // Candidate paths are pushed without pre-checking existence, so
328 // missing/inaccessible dirs are expected here — skip silently.
329 if (!isFsInaccessible(error)) {
330 logError(error)
331 }
332 return []
333 }
334 }),
335 )
336
337 // Flatten and sort all lockfiles by last modified date (newest first)
338 return allLockfiles
339 .flat()
340 .sort((a, b) => b.mtime.getTime() - a.mtime.getTime())
341 .map(file => file.path)
342 } catch (error) {
343 logError(error as Error)
344 return []
345 }
346}
347
348async function readIdeLockfile(path: string): Promise<IdeLockfileInfo | null> {
349 try {

Callers 3

cleanupStaleIdeLockfilesFunction · 0.85
detectIDEsFunction · 0.85
isRelevantFunction · 0.85

Calls 4

getIdeLockfilesPathsFunction · 0.85
getFsImplementationFunction · 0.85
isFsInaccessibleFunction · 0.85
logErrorFunction · 0.70

Tested by

no test coverage detected