Update app/common/src/main/java/stirling/software/common/util/GeneralUtils.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Ludy 2025-07-19 02:08:43 +02:00 committed by GitHub
parent 50bd3bc759
commit 5e86fc0d66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -453,15 +453,19 @@ public class GeneralUtils {
// 2. create a temporary directory
Path tmpDir = Files.createTempDirectory("stirling-pdf-scripts");
tmpDir.toFile().deleteOnExit();
// 3. Copy the file
Path scriptFile = tmpDir.resolve(scriptName);
try (InputStream in = resource.getInputStream()) {
Files.copy(in, scriptFile, StandardCopyOption.REPLACE_EXISTING);
}
return scriptFile;
} finally {
try {
Files.deleteIfExists(scriptFile);
Files.deleteIfExists(tmpDir);
} catch (IOException e) {
log.warn("Failed to delete temporary files: {}", e.getMessage());
}
}
}
public static boolean isVersionHigher(String currentVersion, String compareVersion) {