Skip to content

Commit 9411f93

Browse files
committed
fix regression from coderabbit comment
1 parent f373d50 commit 9411f93

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

‎plugin-manager/src/main/kotlin/com/itsaky/androidide/plugins/manager/services/IdeProjectServiceImpl.kt‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,21 @@ class IdeProjectServiceImpl(
130130
}
131131

132132
return allowedPaths.any { allowedPath ->
133-
canonicalPath.startsWith(allowedPath)
133+
canonicalPath == allowedPath || canonicalPath.startsWith(allowedPath + File.separator)
134134
}
135135
}
136136

137137
private fun getDefaultAllowedPaths(): List<String> {
138-
return listOf(
139-
"/storage/emulated/0/AndroidIDEProjects",
140-
"/sdcard/AndroidIDEProjects",
141-
System.getProperty("user.home", "/") + "/AndroidIDEProjects",
142-
"/tmp/AndroidIDEProject" // Allow temporary project for demo purposes
143-
)
138+
// Derive allowed roots from the official project API (IdeProjectService /
139+
// ProjectProvider) rather than hardcoding a projects-directory name. CodeOnTheGo
140+
// stores projects under CodeOnTheGoProjects and a project
141+
// can live anywhere the user opened it, so the open project's rootDir is the source
142+
// of truth for what this plugin may read.
143+
val roots = mutableListOf<File>()
144+
runCatching {
145+
projectProvider.getCurrentProject()?.rootDir?.let { roots.add(it) }
146+
projectProvider.getAllProjects().forEach { roots.add(it.rootDir) }
147+
}
148+
return roots.mapNotNull { root -> runCatching { root.canonicalPath }.getOrNull() }
144149
}
145150
}

0 commit comments

Comments
 (0)