Skip to content

Commit

Permalink
Switch to Files.createTempDirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-p committed Dec 3, 2024
1 parent 5304aa4 commit 367ecc0
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,10 @@ public static AsyncProfiler getAsyncProfiler() {
private static String deployLibrary() throws IOException {
final String fileName = libraryFileName();
final String userName = System.getProperty("user.name");
final String tmpDir = System.getProperty("java.io.tmpdir");
final File targetDir = new File(tmpDir, userName + "-pyroscope/");
targetDir.mkdirs();

final Path target = targetDir.toPath().resolve(targetLibraryFileName(fileName)).toAbsolutePath();
if (Files.exists(target)) {
// library already deployed
return target.toString();
}
final Path targetDir = Files.createTempDirectory( userName + "-pyroscope");

try (final InputStream is = loadResource(fileName)) {
final Path target = targetDir.resolve(targetLibraryFileName(fileName)).toAbsolutePath();
Files.copy(is, target, StandardCopyOption.REPLACE_EXISTING);
return target.toString();
}
Expand Down

0 comments on commit 367ecc0

Please sign in to comment.