BibDatabaseContext on every BibDatabaseContextChangedEvent.
An intelligent ExecutorService with a BlockingQueue prevents a high load while making backups and
rejects all redundant backup tasks. This class does not manage the .bak file which is created when opening a
database.
| 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 PreferencesService | |
| private static Set |
| Access | Constructor and Description |
|---|---|
| pack-priv | BackupManager(LibraryTab libraryTab, BibDatabaseContext bibDatabaseContext, BibEntryTypesManager entryTypesManager, PreferencesService 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 | |
| private 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 void | 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, BibEntryTypesManager entryTypesManager, PreferencesService 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 | |
| changeFilter | back to summary |
|---|---|
| private final CoarseChangeFilter changeFilter | |
| 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 PreferencesService preferences | |
| runningInstances | back to summary |
|---|---|
| private static Set<BackupManager> runningInstances | |
| BackupManager | back to summary |
|---|---|
| pack-priv BackupManager(LibraryTab libraryTab, BibDatabaseContext bibDatabaseContext, BibEntryTypesManager entryTypesManager, PreferencesService 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)
| |
| logIfCritical | back to summary |
|---|---|
| private void logIfCritical(Path backupPath, IOException e) | |
| 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 void restoreBackup(Path originalPath, Path backupDir) 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, BibEntryTypesManager entryTypesManager, PreferencesService preferences) Starts the BackupManager which is associated with the given
| |
| startBackupTask | back to summary |
|---|---|
| private void startBackupTask(Path backupDir) | |