BibDatabaseContext on every BibDatabaseContextChangedEvent.
An intelligent java.util.concurrent.ExecutorService with a java.util.concurrent.BlockingQueue prevents a high load while making backups and
rejects all redundant backup tasks. This class does not manage org.jabref.logic.util.BackupFileType#SAVE file.
| Modifier and Type | Class and Description |
|---|---|
| public static interface |
| Modifier and Type | Field and Description |
|---|---|
| private final Queue | |
| private final BibDatabaseContext | |
| private final CoarseChangeFilter | |
| private static final int | |
| private final BibEntryTypesManager | |
| private final ScheduledThreadPoolExecutor | |
| private final LibraryTab | |
| private static final Logger | |
| private static final int | |
| private boolean | |
| private final CliPreferences | |
| private static final Set |
| Access | Constructor and Description |
|---|---|
| pack-priv | BackupManager(LibraryTab libraryTab, BibDatabaseContext bibDatabaseContext, CoarseChangeFilter coarseChangeFilter, BibEntryTypesManager entryTypesManager, CliPreferences preferences)
|
| Modifier and Type | Method and Description |
|---|---|
| public static boolean | Returns: true if backup file exists AND differs from originalPath. false is the
"default" return value in the good case. In case a discarded file exists, false is returned, too.
In the case of an exception true is returned to ensure that the user checks the output.Path to the file a backup should be checked for. Example: jabref.bib. originalPath, Path backupDir)Checks whether a backup file exists for the given database file. |
| pack-priv Optional | |
| private static Path | |
| public static void | discardBackup(BibDatabaseContext
Associated bibDatabaseContext, Path backupDir)BibDatabaseContextMarks the backup as discarded at the library which is associated with the given |
| public void | |
| private void | |
| pack-priv static Path | getBackupPathForNewBackup(Path originalPath, Path backupDir)
Determines the most recent backup file name |
| pack-priv static Optional | getLatestBackupPath(Path originalPath, Path backupDir)
Determines the most recent existing backup file name |
| public synchronized void | |
| pack-priv void | performBackup(Path
the full path to the file where the library should be backed up to backupPath)This method is called as soon as the scheduler says: "Do the backup" SIDE EFFECT: Deletes oldest backup file |
| public static BackupManager. | restoreBackup(Path
Path to the file which should be equalized to the backup file. originalPath, Path backupDir)Restores the backup file by copying and overwriting the original one. |
| public static void | shutdown(BibDatabaseContext
Associated bibDatabaseContext, Path BibDatabaseContextThe path to the backup directory backupDir, boolean True, if a backup should be created createBackup)Shuts down the BackupManager which is associated with the given |
| private void | shutdown(Path
The backup directory backupDir, boolean If the backup manager should still perform a backup createBackup)Unregisters the BackupManager from the eventBus of |
| public static BackupManager | start(LibraryTab libraryTab, BibDatabaseContext
Associated bibDatabaseContext, CoarseChangeFilter coarseChangeFilter, BibEntryTypesManager entryTypesManager, CliPreferences preferences)BibDatabaseContextStarts the BackupManager which is associated with the given |
| private void |
| backupFilesQueue | back to summary |
|---|---|
| private final Queue<Path> backupFilesQueue | |
| bibDatabaseContext | back to summary |
|---|---|
| private final BibDatabaseContext bibDatabaseContext | |
| coarseChangeFilter | back to summary |
|---|---|
| private final CoarseChangeFilter coarseChangeFilter | |
| DELAY_BETWEEN_BACKUP_ATTEMPTS_IN_SECONDS | back to summary |
|---|---|
| private static final int DELAY_BETWEEN_BACKUP_ATTEMPTS_IN_SECONDS | |
| entryTypesManager | back to summary |
|---|---|
| private final BibEntryTypesManager entryTypesManager | |
| executor | back to summary |
|---|---|
| private final ScheduledThreadPoolExecutor executor | |
| libraryTab | back to summary |
|---|---|
| private final LibraryTab libraryTab | |
| LOGGER | back to summary |
|---|---|
| private static final Logger LOGGER | |
| MAXIMUM_BACKUP_FILE_COUNT | back to summary |
|---|---|
| private static final int MAXIMUM_BACKUP_FILE_COUNT | |
| needsBackup | back to summary |
|---|---|
| private boolean needsBackup | |
| preferences | back to summary |
|---|---|
| private final CliPreferences preferences | |
| RUNNING_INSTANCES | back to summary |
|---|---|
| private static final Set<BackupManager> RUNNING_INSTANCES | |
| BackupManager | back to summary |
|---|---|
| pack-priv BackupManager(LibraryTab libraryTab, BibDatabaseContext bibDatabaseContext, CoarseChangeFilter coarseChangeFilter, BibEntryTypesManager entryTypesManager, CliPreferences preferences) | |
| backupFileDiffers | back to summary |
|---|---|
| public static boolean backupFileDiffers(Path originalPath, Path backupDir) Checks whether a backup file exists for the given database file. If it exists, it is checked whether it is newer and different from the original. In case a discarded file is present, the method also returns
| |
| determineBackupPathForNewBackup | back to summary |
|---|---|
| pack-priv Optional | |
| determineDiscardedFile | back to summary |
|---|---|
| private static Path determineDiscardedFile(Path file, Path backupDir) | |
| discardBackup | back to summary |
|---|---|
| public static void discardBackup(BibDatabaseContext bibDatabaseContext, Path backupDir) Marks the backup as discarded at the library which is associated with the given
| |
| discardBackup | back to summary |
|---|---|
| public void discardBackup(Path backupDir) Marks the backups as discarded. We do not delete any files, because the user might want to recover old backup files. Therefore, we mark discarded backups by a --discarded file. | |
| fillQueue | back to summary |
|---|---|
| private void fillQueue(Path backupDir) | |
| getBackupPathForNewBackup | back to summary |
|---|---|
| pack-priv static Path getBackupPathForNewBackup(Path originalPath, Path backupDir) Determines the most recent backup file name | |
| getLatestBackupPath | back to summary |
|---|---|
| pack-priv static Optional Determines the most recent existing backup file name | |
| listen | back to summary |
|---|---|
public synchronized void listen(BibDatabaseContextChangedEvent event)
| |
| performBackup | back to summary |
|---|---|
| pack-priv void performBackup(Path backupPath) This method is called as soon as the scheduler says: "Do the backup" SIDE EFFECT: Deletes oldest backup file
| |
| restoreBackup | back to summary |
|---|---|
| public static BackupManager. Restores the backup file by copying and overwriting the original one.
| |
| shutdown | back to summary |
|---|---|
| public static void shutdown(BibDatabaseContext bibDatabaseContext, Path backupDir, boolean createBackup) Shuts down the BackupManager which is associated with the given
| |
| shutdown | back to summary |
|---|---|
| private void shutdown(Path backupDir, boolean createBackup) Unregisters the BackupManager from the eventBus of
| |
| start | back to summary |
|---|---|
| public static BackupManager start(LibraryTab libraryTab, BibDatabaseContext bibDatabaseContext, CoarseChangeFilter coarseChangeFilter, BibEntryTypesManager entryTypesManager, CliPreferences preferences) Starts the BackupManager which is associated with the given This method is not thread-safe. The caller has to ensure that this method is not called in parallel.
| |
| startBackupTask | back to summary |
|---|---|
| private void startBackupTask(Path backupDir) | |
| Modifier and Type | Class and Description |
|---|---|
| public static record | |
| public static record | |
| public static record | |
| public static record |
| Modifier and Type | Field and Description |
|---|---|
| private final Path | backupPath
Record Component accessed by backupPath(). |
| Modifier and Type | Method and Description |
|---|---|
| public Path | |
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public final int | |
| public final String | toString()
Implements abstract java. Returns a string representation of the record. |
| backupPath | back to summary |
|---|---|
| private final Path backupPath Record Component accessed by backupPath(). | |
| Empty | back to summary |
|---|---|
| public Empty(Path backupPath) | |
| backupPath | back to summary |
|---|---|
| public Path backupPath() Record Component getter of backupPath. | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of | |
| toString | back to summary |
|---|---|
| public final String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves. | |
| Modifier and Type | Field and Description |
|---|---|
| private final Path | backupPath
Record Component accessed by backupPath(). |
| private final IOException | exception
Record Component accessed by exception(). |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Path | |
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public IOException | |
| public final int | |
| public final String | toString()
Implements abstract java. Returns a string representation of the record. |
| backupPath | back to summary |
|---|---|
| private final Path backupPath Record Component accessed by backupPath(). | |
| exception | back to summary |
|---|---|
| private final IOException exception Record Component accessed by exception(). | |
| Failed | back to summary |
|---|---|
| public Failed(Path backupPath, IOException exception) | |
| backupPath | back to summary |
|---|---|
| public Path backupPath() Record Component getter of backupPath. | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| exception | back to summary |
|---|---|
| public IOException exception() Record Component getter of exception. | |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of | |
| toString | back to summary |
|---|---|
| public final String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves. | |
| Modifier and Type | Field and Description |
|---|---|
| private final Path | originalPath
Record Component accessed by originalPath(). |
| Modifier and Type | Method and Description |
|---|---|
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public final int | |
| public Path | |
| public final String | toString()
Implements abstract java. Returns a string representation of the record. |
| originalPath | back to summary |
|---|---|
| private final Path originalPath Record Component accessed by originalPath(). | |
| NotFound | back to summary |
|---|---|
| public NotFound(Path originalPath) | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of | |
| originalPath | back to summary |
|---|---|
| public Path originalPath() Record Component getter of originalPath. | |
| toString | back to summary |
|---|---|
| public final String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves. | |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public final int | |
| public final String | toString()
Implements abstract java. Returns a string representation of the record. |
| Restored | back to summary |
|---|---|
| public Restored() | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of | |
| toString | back to summary |
|---|---|
| public final String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves. | |