Verified Owner
Top Description Fields Constructors Methods
org.jabref.gui.git

public Class GitPullScheduler

extends Object
Class Inheritance
Annotations
@NullMarked
Imports
java.nio.file.Path, java.util.HashSet, .Optional, .Set, java.util.concurrent.ScheduledThreadPoolExecutor, .TimeUnit, java.util.function.BooleanSupplier, org.jabref.gui.DialogService, .StateManager, org.jabref.gui.preferences.GuiPreferences, org.jabref.logic.git.GitHandler, org.jabref.logic.git.util.GitHandlerRegistry, org.jabref.logic.util.TaskExecutor, org.jabref.model.database.BibDatabaseContext, org.jspecify.annotations.NullMarked, org.slf4j.Logger, .LoggerFactory

Pulls remote changes for a library at the interval configured in the Git preferences.

A scheduler is only started for a library stored inside a Git repository. The "Regularly pull remote changes" setting is read on every run, so switching it takes effect without reopening the library, the interval is read once, when the scheduler starts.

Field Summary

Modifier and TypeField and Description
private final BibDatabaseContext
private final ScheduledThreadPoolExecutor
private final BooleanSupplier
private static final Logger
private static final Set<GitPullScheduler>

Constructor Summary

AccessConstructor and Description
private
GitPullScheduler(BibDatabaseContext bibDatabaseContext, GitAutoSync gitAutoSync, BooleanSupplier hasUnsavedChanges, int intervalInMinutes)

Method Summary

Modifier and TypeMethod and Description
pack-priv static boolean
isRunning(BibDatabaseContext bibDatabaseContext)

private void
pull(GitAutoSync gitAutoSync)

Runs one scheduled pull.

public static void
shutdown(BibDatabaseContext bibDatabaseContext)

Shuts down the scheduler which is associated with the given BibDatabaseContext.

public static void
start(BibDatabaseContext bibDatabaseContext, DialogService dialogService, GuiPreferences preferences, StateManager stateManager, TaskExecutor taskExecutor, GitHandlerRegistry gitHandlerRegistry, BooleanSupplier hasUnsavedChanges)

Starts the scheduler for the given library, if it is stored inside a Git repository and has no scheduler yet.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bibDatabaseContextback to summary
private final BibDatabaseContext bibDatabaseContext
executorback to summary
private final ScheduledThreadPoolExecutor executor
hasUnsavedChangesback to summary
private final BooleanSupplier hasUnsavedChanges
LOGGERback to summary
private static final Logger LOGGER
RUNNING_INSTANCESback to summary
private static final Set<GitPullScheduler> RUNNING_INSTANCES

Constructor Detail

GitPullSchedulerback to summary
private GitPullScheduler(BibDatabaseContext bibDatabaseContext, GitAutoSync gitAutoSync, BooleanSupplier hasUnsavedChanges, int intervalInMinutes)

Method Detail

isRunningback to summary
pack-priv static boolean isRunning(BibDatabaseContext bibDatabaseContext)
pullback to summary
private void pull(GitAutoSync gitAutoSync)

Runs one scheduled pull. Skips while the library has unsaved changes, because a merge would be applied underneath the user's edits. Exceptions are caught, because scheduleAtFixedRate silently cancels the schedule for the rest of the session if the task throws.

shutdownback to summary
public static void shutdown(BibDatabaseContext bibDatabaseContext)

Shuts down the scheduler which is associated with the given BibDatabaseContext.

Parameters
bibDatabaseContext:BibDatabaseContext

Associated BibDatabaseContext

startback to summary
public static void start(BibDatabaseContext bibDatabaseContext, DialogService dialogService, GuiPreferences preferences, StateManager stateManager, TaskExecutor taskExecutor, GitHandlerRegistry gitHandlerRegistry, BooleanSupplier hasUnsavedChanges)

Starts the scheduler for the given library, if it is stored inside a Git repository and has no scheduler yet.

This method is not thread-safe. The caller has to ensure that this method is not called in parallel.

Parameters
bibDatabaseContext:BibDatabaseContext

Associated BibDatabaseContext