getSortedIdeLockfiles method
Gets sorted IDE lockfiles from ~/.neomage/ide directory.
Implementation
Future<List<String>> getSortedIdeLockfiles() async {
try {
final ideLockFilePaths = await getIdeLockfilesPaths();
final allLockfiles = <({String path, DateTime mtime})>[];
for (final ideLockFilePath in ideLockFilePaths) {
try {
final dir = Directory(ideLockFilePath);
if (!await dir.exists()) continue;
await for (final file in dir.list()) {
if (file is File && file.path.endsWith('.lock')) {
try {
final stat = await file.stat();
allLockfiles.add((path: file.path, mtime: stat.modified));
} catch (_) {}
}
}
} catch (e) {
_logError(e);
}
}
// Sort by modification time (newest first)
allLockfiles.sort((a, b) => b.mtime.compareTo(a.mtime));
return allLockfiles.map((f) => f.path).toList();
} catch (e) {
_logError(e);
return [];
}
}