mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-08 17:51:20 +02:00
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:
parent
50bd3bc759
commit
5e86fc0d66
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user