@@ -53,12 +53,17 @@ class OdooLSInstallationProjectActivity : ProjectActivity, DumbAware {
5353 }
5454
5555 fun copyDirectoryFromResourcesToInstallLocation (directoryPath : String , targetPath : String ) {
56- val targetLocation = Paths .get(targetPath, " typeshed " )
56+ val targetLocation = Paths .get(targetPath, directoryPath )
5757 val resourceUrl = javaClass.classLoader.getResource(directoryPath)
5858 ? : throw IllegalArgumentException (" Resource not found: $directoryPath " )
5959
6060 if (resourceUrl.protocol == " jar" ) {
61- val fileSystem = FileSystems .newFileSystem(resourceUrl.toURI(), emptyMap<String , Any >())
61+ val uri = resourceUrl.toURI()
62+ val fileSystem = try {
63+ FileSystems .getFileSystem(uri)
64+ } catch (e: java.nio.file.FileSystemNotFoundException ) {
65+ FileSystems .newFileSystem(uri, emptyMap<String , Any >())
66+ }
6267 val jarPath = fileSystem.getPath(directoryPath)
6368 Files .walk(jarPath).forEach { source ->
6469 val dest = targetLocation.resolve(jarPath.relativize(source).toString())
@@ -82,7 +87,7 @@ class OdooLSInstallationProjectActivity : ProjectActivity, DumbAware {
8287 }
8388 }
8489
85- fun ressourceToInstallPath (resourcePath : String , targetPath : Path ) {
90+ fun resourceToInstallPath (resourcePath : String , targetPath : Path ) {
8691 javaClass.classLoader.getResourceAsStream(resourcePath).use { input ->
8792 requireNotNull(input) { " Resource not found: $resourcePath " }
8893 try {
@@ -192,23 +197,31 @@ class OdooLSInstallationProjectActivity : ProjectActivity, DumbAware {
192197
193198 installedVersionOlder(Paths .get(targetLocation, exeName)) { isOlder ->
194199 if (isOlder) {
195- ressourceToInstallPath (" odools-binaries/${targetOs} /$exeName " , Paths .get(targetLocation, exeName))
200+ resourceToInstallPath (" odools-binaries/${targetOs} /$exeName " , Paths .get(targetLocation, exeName))
196201
197202 if (SystemInfo .isWindows &&
198203 (! Files .exists(Paths .get(targetLocation, " odoo_ls_server.pdb" )))) {
199- ressourceToInstallPath (" odools-binaries/${targetOs} /odoo_ls_server.pdb" , Paths .get(targetLocation, " odoo_ls_server.pdb" ))
204+ resourceToInstallPath (" odools-binaries/${targetOs} /odoo_ls_server.pdb" , Paths .get(targetLocation, " odoo_ls_server.pdb" ))
200205 }
201206 if (! SystemInfo .isWindows) {
202207 Paths .get(targetLocation, exeName).toFile().setExecutable(true , false )
203208 }
204209 }
205- if (! Files .exists(Paths .get(targetLocation, " typeshed" )) && isTypeshedOutDated(Paths .get(targetLocation, " typeshed" ))) {
210+ if (! Files .exists(Paths .get(targetLocation, " typeshed" )) || isTypeshedOutDated(Paths .get(targetLocation, " typeshed" ))) {
206211 val file = Paths .get(targetLocation, " typeshed" ).toFile()
207212 if (file.exists()) {
208213 file.deleteRecursively()
209214 }
210215 copyDirectoryFromResourcesToInstallLocation(" typeshed" , targetLocation)
211216 }
217+ if (! Files .exists(Paths .get(targetLocation, " additional_stubs" ))) {
218+ val file = Paths .get(targetLocation, " additional_stubs" ).toFile()
219+ if (file.exists()) {
220+ file.deleteRecursively()
221+ }
222+ copyDirectoryFromResourcesToInstallLocation(" additional_stubs" , targetLocation)
223+
224+ }
212225 println (" Installation complete" )
213226 callback()
214227 }
0 commit comments