mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-08 17:51:20 +02:00
Update GeneralUtils.java
This commit is contained in:
parent
d395ce6a4f
commit
8d894f2d73
@ -467,18 +467,13 @@ public class GeneralUtils {
|
|||||||
|
|
||||||
// 2. create a temporary directory
|
// 2. create a temporary directory
|
||||||
Path tmpDir = Files.createTempDirectory("stirling-pdf-scripts");
|
Path tmpDir = Files.createTempDirectory("stirling-pdf-scripts");
|
||||||
Path scriptFile = tmpDir.resolve(scriptName);
|
tmpDir.toFile().deleteOnExit();
|
||||||
|
|
||||||
|
// 3. copy the script to the temporary directory
|
||||||
|
Path scriptFile = tmpDir.resolve(scriptName);
|
||||||
try (InputStream in = resource.getInputStream()) {
|
try (InputStream in = resource.getInputStream()) {
|
||||||
Files.copy(in, scriptFile, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(in, scriptFile, StandardCopyOption.REPLACE_EXISTING);
|
||||||
return scriptFile;
|
return scriptFile;
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
Files.deleteIfExists(scriptFile);
|
|
||||||
Files.deleteIfExists(tmpDir);
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.warn("Failed to delete temporary files: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user