From 05366973b0b8379616c0c75304535018c892e918 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Wed, 5 Feb 2025 18:32:47 +0100 Subject: [PATCH] Fix BibTexStrings not included in backup file Fixes https://github.com/JabRef/jabref/issues/12462 --- CHANGELOG.md | 1 + .../org/jabref/gui/autosaveandbackup/BackupManager.java | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9ecede44ef..bccf8db02be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue where removing the sort from the table did not restore the original order. [#12371](https://github.com/JabRef/jabref/pull/12371) - We fixed an issue where JabRef icon merges with dark background [#7771](https://github.com/JabRef/jabref/issues/7771) - We fixed an issue where an entry's group was no longer highlighted on selection [#12413](https://github.com/JabRef/jabref/issues/12413) +- We fixed an issue where BibTeX Strings were not included in the backup file [#12462](https://github.com/JabRef/jabref/issues/12462) ### Removed diff --git a/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java b/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java index acae02c01c8..0f34ae90d03 100644 --- a/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java +++ b/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java @@ -38,6 +38,7 @@ import org.jabref.model.database.event.BibDatabaseContextChangedEvent; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BibEntryTypesManager; +import org.jabref.model.entry.BibtexString; import org.jabref.model.metadata.SaveOrder; import org.jabref.model.metadata.SelfContainedSaveOrder; @@ -59,7 +60,7 @@ public class BackupManager { private static final int DELAY_BETWEEN_BACKUP_ATTEMPTS_IN_SECONDS = 19; - private static Set runningInstances = new HashSet<>(); + private static final Set runningInstances = new HashSet<>(); private final BibDatabaseContext bibDatabaseContext; private final CliPreferences preferences; @@ -268,6 +269,9 @@ void performBackup(Path backupPath) { .map(BibEntry.class::cast) .toList(); BibDatabase bibDatabaseClone = new BibDatabase(list); + bibDatabaseContext.getDatabase().getStringValues().stream().map(BibtexString::clone) + .map(BibtexString.class::cast) + .forEach(bibDatabaseClone::addString); BibDatabaseContext bibDatabaseContextClone = new BibDatabaseContext(bibDatabaseClone, bibDatabaseContext.getMetaData()); Charset encoding = bibDatabaseContext.getMetaData().getEncoding().orElse(StandardCharsets.UTF_8);