Skip to content

Commit a2d529c

Browse files
authored
Set Dependency Override to just a empty path, make nested jars directory clear before extracting to not accumulate dependencies from different launches (#1)
1 parent a74f3c1 commit a2d529c

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/main/kotlin/com/lambda/loader/util/FabricUtil.kt

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,23 @@ object FabricUtil {
5959
/**
6060
* Loads nested JARs from META-INF/jars/ directory and adds them to classpath
6161
* Fabric Loader stores bundled dependencies in this directory for jar-in-jar functionality
62-
* Extracts nested JARs to temp directory for classpath access
62+
* Extracts nested JARs to a consistent temp directory that's cleared on each run
6363
*/
6464
fun loadNestedJars(jarFile: File): List<Path> {
6565
val nestedJarPaths = mutableListOf<Path>()
6666

6767
try {
68-
// Create temp directory for nested JARs
69-
val tempDir = Files.createTempDirectory("lambda-loader-nested")
68+
// Use a consistent temp directory location
69+
val tempDir = Path.of(System.getProperty("java.io.tmpdir"), "lambda-loader-nested")
70+
71+
// Clear the directory if it exists, then recreate it
72+
if (Files.exists(tempDir)) {
73+
Files.walk(tempDir)
74+
.sorted(Comparator.reverseOrder())
75+
.forEach { Files.deleteIfExists(it) }
76+
}
77+
Files.createDirectories(tempDir)
78+
7079
if (ConfigManager.config.debug) {
7180
logger.info("Created temp directory for nested JARs: $tempDir")
7281
}
@@ -143,10 +152,8 @@ object FabricUtil {
143152

144153
val versionOverrides = VersionOverrides()
145154

146-
// DependencyOverrides takes a Path parameter - use a temporary directory
147-
val tempPath = Files.createTempDirectory("lambda-loader-deps")
148-
val depOverrides = DependencyOverrides(tempPath)
149-
155+
// DependencyOverrides takes a Path parameter - use empty path since it isn't used
156+
val depOverrides = DependencyOverrides(Path.of(""))
150157
val metadata = parseMetadataMethod.invoke(
151158
null, // static method
152159
zip.getInputStream(entry),

0 commit comments

Comments
 (0)