]> git.basschouten.com Git - openhab-addons.git/commitdiff
[porcupineks] fix null pointer exception and file bundle extraction on Windows OS...
authorGiviMAD <GiviMAD@users.noreply.github.com>
Mon, 7 Feb 2022 17:53:14 +0000 (18:53 +0100)
committerGitHub <noreply@github.com>
Mon, 7 Feb 2022 17:53:14 +0000 (18:53 +0100)
Signed-off-by: Miguel Álvarez Díez <miguelwork92@gmail.com>
bundles/org.openhab.voice.porcupineks/src/main/java/org/openhab/voice/porcupineks/internal/PorcupineKSService.java

index 41f44f5c101002424e9e8080c9aa74cfbb051290..c5174bae88aa469b05ac24e00fa84024ef2f2cf4 100644 (file)
@@ -120,8 +120,16 @@ public class PorcupineKSService implements KSService {
         File localFile = new File(EXTRACTION_FOLDER,
                 relativePath.substring(relativePath.lastIndexOf(File.separator) + 1));
         if (!localFile.exists()) {
+            if (File.separator.equals("\\")) {
+                // bundle requires unix path separator
+                logger.debug("use unix path separator");
+                relativePath = relativePath.replace("\\", "/");
+            }
             URL porcupineResource = bundleContext.getBundle().getEntry(relativePath);
             logger.debug("extracting binary {} from bundle to extraction folder", relativePath);
+            if (porcupineResource == null) {
+                throw new IOException("Missing bundle file: " + relativePath);
+            }
             extractFromBundle(porcupineResource, localFile);
         } else {
             logger.debug("binary {} already extracted", relativePath);