[porcupineks] fix null pointer exception and file bundle extraction on Windows OS (#12234)
Signed-off-by: Miguel Álvarez Díez <miguelwork92@gmail.com>
This commit is contained in:
parent
d46367dfd0
commit
4e6bc0976e
|
@ -120,8 +120,16 @@ public class PorcupineKSService implements KSService {
|
||||||
File localFile = new File(EXTRACTION_FOLDER,
|
File localFile = new File(EXTRACTION_FOLDER,
|
||||||
relativePath.substring(relativePath.lastIndexOf(File.separator) + 1));
|
relativePath.substring(relativePath.lastIndexOf(File.separator) + 1));
|
||||||
if (!localFile.exists()) {
|
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);
|
URL porcupineResource = bundleContext.getBundle().getEntry(relativePath);
|
||||||
logger.debug("extracting binary {} from bundle to extraction folder", relativePath);
|
logger.debug("extracting binary {} from bundle to extraction folder", relativePath);
|
||||||
|
if (porcupineResource == null) {
|
||||||
|
throw new IOException("Missing bundle file: " + relativePath);
|
||||||
|
}
|
||||||
extractFromBundle(porcupineResource, localFile);
|
extractFromBundle(porcupineResource, localFile);
|
||||||
} else {
|
} else {
|
||||||
logger.debug("binary {} already extracted", relativePath);
|
logger.debug("binary {} already extracted", relativePath);
|
||||||
|
|
Loading…
Reference in New Issue