From 0191910c7994cacab90d4200e4bcf5243c9949c5 Mon Sep 17 00:00:00 2001 From: antalk2 Date: Thu, 10 Jun 2021 23:06:00 +0200 Subject: [PATCH] cleanup temporary files, use prefix "jabref-" (#7811) --- .../org/jabref/logic/journals/JournalAbbreviationLoader.java | 5 ++++- src/main/java/org/jabref/logic/net/URLDownload.java | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/logic/journals/JournalAbbreviationLoader.java b/src/main/java/org/jabref/logic/journals/JournalAbbreviationLoader.java index 72f0664b046..cf7d6a177ed 100644 --- a/src/main/java/org/jabref/logic/journals/JournalAbbreviationLoader.java +++ b/src/main/java/org/jabref/logic/journals/JournalAbbreviationLoader.java @@ -25,9 +25,12 @@ public static JournalAbbreviationRepository loadRepository(JournalAbbreviationPr JournalAbbreviationRepository repository; // Initialize with built-in list try { - Path tempJournalList = Files.createTempDirectory("journal").resolve("journalList.mv"); + Path tempDir = Files.createTempDirectory("jabref-journal"); + Path tempJournalList = tempDir.resolve("journalList.mv"); Files.copy(JournalAbbreviationRepository.class.getResourceAsStream("/journals/journalList.mv"), tempJournalList); repository = new JournalAbbreviationRepository(tempJournalList); + tempDir.toFile().deleteOnExit(); + tempJournalList.toFile().deleteOnExit(); } catch (IOException e) { LOGGER.error("Error while copying journal list", e); return null; diff --git a/src/main/java/org/jabref/logic/net/URLDownload.java b/src/main/java/org/jabref/logic/net/URLDownload.java index de94af68dc5..f0c5f778d08 100644 --- a/src/main/java/org/jabref/logic/net/URLDownload.java +++ b/src/main/java/org/jabref/logic/net/URLDownload.java @@ -305,11 +305,12 @@ public Path toTemporaryFile() throws IOException { // Take everything after the last '/' as name + extension String fileNameWithExtension = sourcePath.substring(sourcePath.lastIndexOf('/') + 1); - String fileName = FileUtil.getBaseName(fileNameWithExtension); + String fileName = "jabref-" + FileUtil.getBaseName(fileNameWithExtension); String extension = "." + FileHelper.getFileExtension(fileNameWithExtension).orElse("tmp"); // Create temporary file and download to it Path file = Files.createTempFile(fileName, extension); + file.toFile().deleteOnExit(); toFile(file); return file;