fix(StorageServiceImpl, StaticResourceServiceImpl): handle nested jar paths when resolving parent directory
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>de.extio</groupId>
|
<groupId>de.extio</groupId>
|
||||||
<artifactId>game-engine</artifactId>
|
<artifactId>game-engine</artifactId>
|
||||||
<version>1.0.22</version>
|
<version>1.0.23</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>25</java.version>
|
<java.version>25</java.version>
|
||||||
|
|||||||
@@ -28,7 +28,13 @@ public class StaticResourceServiceImpl implements StaticResourceService {
|
|||||||
if (location == null) {
|
if (location == null) {
|
||||||
try {
|
try {
|
||||||
final URL url = StorageServiceImpl.class.getProtectionDomain().getCodeSource().getLocation();
|
final URL url = StorageServiceImpl.class.getProtectionDomain().getCodeSource().getLocation();
|
||||||
final Path parent = Paths.get(url.toURI()).getParent();
|
Path parent;
|
||||||
|
if (url.toString().startsWith("jar:nested:")) {
|
||||||
|
parent = Paths.get(url.toString().substring("jar:nested:".length(), url.toString().indexOf("/!"))).getParent();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
parent = Paths.get(url.toURI()).getParent();
|
||||||
|
}
|
||||||
final Path jarPath = parent != null ? parent.toAbsolutePath().normalize() : Paths.get(url.toURI()).toAbsolutePath().normalize();
|
final Path jarPath = parent != null ? parent.toAbsolutePath().normalize() : Paths.get(url.toURI()).toAbsolutePath().normalize();
|
||||||
|
|
||||||
final String currentSubDir = jarPath.getFileName().toString();
|
final String currentSubDir = jarPath.getFileName().toString();
|
||||||
|
|||||||
@@ -38,7 +38,13 @@ public class StorageServiceImpl implements StorageService {
|
|||||||
if (location == null) {
|
if (location == null) {
|
||||||
try {
|
try {
|
||||||
final URL url = StorageServiceImpl.class.getProtectionDomain().getCodeSource().getLocation();
|
final URL url = StorageServiceImpl.class.getProtectionDomain().getCodeSource().getLocation();
|
||||||
final Path parent = Paths.get(url.toURI()).getParent();
|
Path parent;
|
||||||
|
if (url.toString().startsWith("jar:nested:")) {
|
||||||
|
parent = Paths.get(url.toString().substring("jar:nested:".length(), url.toString().indexOf("/!"))).getParent();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
parent = Paths.get(url.toURI()).getParent();
|
||||||
|
}
|
||||||
final Path jarPath = parent != null ? parent.toAbsolutePath().normalize() : Paths.get(url.toURI()).toAbsolutePath().normalize();
|
final Path jarPath = parent != null ? parent.toAbsolutePath().normalize() : Paths.get(url.toURI()).toAbsolutePath().normalize();
|
||||||
|
|
||||||
final String currentSubDir = jarPath.getFileName().toString();
|
final String currentSubDir = jarPath.getFileName().toString();
|
||||||
|
|||||||
Reference in New Issue
Block a user