diff --git a/CHANGELOG.md b/CHANGELOG.md index dd098ff39ea..d0386a4f943 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - 'Get full text' now also checks the file url. [#568](https://github.com/koppor/jabref/issues/568) - JabRef writes a new backup file only if there is a change. Before, JabRef created a backup upon start. [#9679](https://github.com/JabRef/jabref/pull/9679) - We refined the 'main directory not found' error message. [#9625](https://github.com/JabRef/jabref/pull/9625) +- We streamlined the paths for logs and backups: The parent path fragement is always `logs` or `backups`. +- Backups of libraries are not stored per JabRef version, but collected together. - We modified the `Add Group` dialog to use the most recently selected group hierarchical context [#9141](https://github.com/JabRef/jabref/issues/9141) - We improved the Medline importer to correctly import ISO dates for `revised`. [#9536](https://github.com/JabRef/jabref/issues/9536) diff --git a/src/main/java/org/jabref/cli/Launcher.java b/src/main/java/org/jabref/cli/Launcher.java index 1b20af32edb..a0a9f7450f8 100644 --- a/src/main/java/org/jabref/cli/Launcher.java +++ b/src/main/java/org/jabref/cli/Launcher.java @@ -22,6 +22,7 @@ import org.jabref.logic.remote.RemotePreferences; import org.jabref.logic.remote.client.RemoteClient; import org.jabref.logic.util.BuildInfo; +import org.jabref.logic.util.OS; import org.jabref.migrations.PreferencesMigrations; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.database.BibDatabaseMode; @@ -90,10 +91,12 @@ public static void main(String[] args) { * the log configuration programmatically anymore. */ private static void addLogToDisk() { - Path directory = Path.of(AppDirsFactory.getInstance().getUserLogDir( - "jabref", - new BuildInfo().version.toString(), - "org.jabref")); + Path directory = Path.of(AppDirsFactory.getInstance() + .getUserDataDir( + OS.APP_DIR_APP_NAME, + "logs", + OS.APP_DIR_APP_AUTHOR)) + .resolve(new BuildInfo().version.toString()); try { Files.createDirectories(directory); } catch (IOException e) { diff --git a/src/main/java/org/jabref/gui/backup/BackupResolverDialog.java b/src/main/java/org/jabref/gui/backup/BackupResolverDialog.java index 64f24662ecf..bdd2fbd2d16 100644 --- a/src/main/java/org/jabref/gui/backup/BackupResolverDialog.java +++ b/src/main/java/org/jabref/gui/backup/BackupResolverDialog.java @@ -32,7 +32,7 @@ public BackupResolverDialog(Path originalPath) { getDialogPane().setMinHeight(180); getDialogPane().getButtonTypes().setAll(RESTORE_FROM_BACKUP, REVIEW_BACKUP, IGNORE_BACKUP); - Optional backupPathOpt = BackupFileUtil.getPathOfLatestExisingBackupFile(originalPath, BackupFileType.BACKUP); + Optional backupPathOpt = BackupFileUtil.getPathOfLatestExistingBackupFile(originalPath, BackupFileType.BACKUP); String backupFilename = backupPathOpt.map(Path::getFileName).map(Path::toString).orElse(Localization.lang("File not found")); String content = new StringBuilder() .append(Localization.lang("A backup file for '%0' was found at [%1]", diff --git a/src/main/java/org/jabref/gui/dialogs/BackupUIManager.java b/src/main/java/org/jabref/gui/dialogs/BackupUIManager.java index 3c0536bf4af..ceba43dd088 100644 --- a/src/main/java/org/jabref/gui/dialogs/BackupUIManager.java +++ b/src/main/java/org/jabref/gui/dialogs/BackupUIManager.java @@ -63,7 +63,7 @@ private static Optional showReviewBackupDialog(DialogService dialo // This will be modified by using the `DatabaseChangesResolverDialog`. BibDatabaseContext originalDatabase = originalParserResult.getDatabaseContext(); - Path backupPath = BackupFileUtil.getPathOfLatestExisingBackupFile(originalPath, BackupFileType.BACKUP).orElseThrow(); + Path backupPath = BackupFileUtil.getPathOfLatestExistingBackupFile(originalPath, BackupFileType.BACKUP).orElseThrow(); BibDatabaseContext backupDatabase = OpenDatabase.loadDatabase(backupPath, importFormatPreferences, new DummyFileUpdateMonitor()).getDatabaseContext(); DatabaseChangeResolverFactory changeResolverFactory = new DatabaseChangeResolverFactory(dialogService, originalDatabase, preferencesService.getBibEntryPreferences()); diff --git a/src/main/java/org/jabref/logic/autosaveandbackup/BackupManager.java b/src/main/java/org/jabref/logic/autosaveandbackup/BackupManager.java index 99d40ff7d89..789671c0b14 100644 --- a/src/main/java/org/jabref/logic/autosaveandbackup/BackupManager.java +++ b/src/main/java/org/jabref/logic/autosaveandbackup/BackupManager.java @@ -87,7 +87,7 @@ static Path getBackupPathForNewBackup(Path originalPath) { * Determines the most recent existing backup file name */ static Optional getLatestBackupPath(Path originalPath) { - return BackupFileUtil.getPathOfLatestExisingBackupFile(originalPath, BackupFileType.BACKUP); + return BackupFileUtil.getPathOfLatestExistingBackupFile(originalPath, BackupFileType.BACKUP); } /** diff --git a/src/main/java/org/jabref/logic/util/OS.java b/src/main/java/org/jabref/logic/util/OS.java index fabbadbd2c9..52a29bcdedc 100644 --- a/src/main/java/org/jabref/logic/util/OS.java +++ b/src/main/java/org/jabref/logic/util/OS.java @@ -8,7 +8,7 @@ public class OS { public static final String NEWLINE = System.lineSeparator(); - public static final String APP_DIR_APP_NAME = "JabRef"; + public static final String APP_DIR_APP_NAME = "jabref"; public static final String APP_DIR_APP_AUTHOR = "org.jabref"; // File separator obtained from system diff --git a/src/main/java/org/jabref/logic/util/io/BackupFileUtil.java b/src/main/java/org/jabref/logic/util/io/BackupFileUtil.java index f669f2ee567..c378386c1ed 100644 --- a/src/main/java/org/jabref/logic/util/io/BackupFileUtil.java +++ b/src/main/java/org/jabref/logic/util/io/BackupFileUtil.java @@ -10,7 +10,6 @@ import java.util.Optional; import org.jabref.logic.util.BackupFileType; -import org.jabref.logic.util.BuildInfo; import org.jabref.logic.util.OS; import net.harawata.appdirs.AppDirsFactory; @@ -25,11 +24,11 @@ private BackupFileUtil() { } public static Path getAppDataBackupDir() { - Path directory = Path.of(AppDirsFactory.getInstance().getUserDataDir( - OS.APP_DIR_APP_NAME, - new BuildInfo().version.toString(), - OS.APP_DIR_APP_AUTHOR)) - .resolve("backups"); + Path directory = Path.of(AppDirsFactory.getInstance() + .getUserDataDir( + OS.APP_DIR_APP_NAME, + "backups", + OS.APP_DIR_APP_AUTHOR)); return directory; } @@ -72,7 +71,7 @@ public static Path getPathForNewBackupFileAndCreateDirectory(Path targetFile, Ba * * @param targetFile the full path of the file to backup */ - public static Optional getPathOfLatestExisingBackupFile(Path targetFile, BackupFileType fileType) { + public static Optional getPathOfLatestExistingBackupFile(Path targetFile, BackupFileType fileType) { // The code is similar to "getPathForNewBackupFileAndCreateDirectory" String extension = "." + fileType.getExtensions().get(0); diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index f3202faa549..4781e359d7d 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -530,7 +530,10 @@ private JabRefPreferences() { // SSL defaults.put(TRUSTSTORE_PATH, Path.of(AppDirsFactory.getInstance() - .getUserDataDir(OS.APP_DIR_APP_NAME, "ssl", OS.APP_DIR_APP_AUTHOR)) + .getUserDataDir( + OS.APP_DIR_APP_NAME, + "ssl", + OS.APP_DIR_APP_AUTHOR)) .resolve("truststore.jks").toString()); defaults.put(POS_X, 0);