Skip to content

Commit

Permalink
cleanup temporary files, use prefix "jabref-" (#7811)
Browse files Browse the repository at this point in the history
  • Loading branch information
antalk2 authored Jun 10, 2021
1 parent e82b721 commit 0191910
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/logic/net/URLDownload.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0191910

Please sign in to comment.