Rework git init order

This commit is contained in:
crschnick 2024-02-27 04:38:45 +00:00
parent 525916d59d
commit 8e5550c61d
5 changed files with 34 additions and 25 deletions

View file

@ -10,10 +10,12 @@ import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.GitStorageHandler;
import io.xpipe.app.update.XPipeDistributionType;
import io.xpipe.app.util.FileBridge;
import io.xpipe.app.util.LicenseProvider;
import io.xpipe.app.util.LocalShell;
import io.xpipe.app.util.UnlockAlert;
import io.xpipe.core.util.JacksonMapper;
public class BaseMode extends OperationMode {
@ -44,16 +46,19 @@ public class BaseMode extends OperationMode {
JacksonMapper.initModularized(AppExtensionManager.getInstance().getExtendedLayer());
AppI18n.init();
LicenseProvider.get().init();
AppPrefs.init();
AppPrefs.initLocal();
AppCertutilCheck.check();
AppAvCheck.check();
LocalShell.init();
XPipeDistributionType.init();
AppShellCheck.check();
AppPrefs.setDefaults();
// Initialize socket server before storage
// as we should be prepared for git askpass commands
// Initialize socket server as we should be prepared for git askpass commands
AppSocketServer.init();
GitStorageHandler.getInstance().init();
GitStorageHandler.getInstance().setupRepositoryAndPull();
AppPrefs.initSharedRemote();
UnlockAlert.showIfNeeded();
DataStorage.init();
AppFileWatcher.init();
FileBridge.init();

View file

@ -153,11 +153,14 @@ public class AppPrefs {
categories.get(selected >= 0 && selected < categories.size() ? selected : 0));
}
public static void init() {
public static void initLocal() {
INSTANCE = new AppPrefs();
PrefsProvider.getAll().forEach(prov -> prov.addPrefs(INSTANCE.extensionHandler));
INSTANCE.load();
INSTANCE.loadLocal();
}
public static void initSharedRemote() {
INSTANCE.loadSharedRemote();
INSTANCE.encryptAllVaultData.addListener((observableValue, aBoolean, t1) -> {
if (DataStorage.get() != null) {
DataStorage.get().forceRewrite();
@ -417,16 +420,28 @@ public class AppPrefs {
.orElseThrow();
}
public void load() {
private void loadLocal() {
for (Mapping<?> value : mapping) {
if (value.isVaultSpecific()) {
continue;
}
loadValue(globalStorageHandler, value);
}
}
private void loadSharedRemote() {
for (Mapping<?> value : mapping) {
if (!value.isVaultSpecific()) {
continue;
}
var def = value.getProperty().getValue();
AppPrefsStorageHandler handler = value.isVaultSpecific() ? vaultStorageHandler : globalStorageHandler;
var r = loadValue(handler, value);
var r = loadValue(vaultStorageHandler, value);
// This can be used to facilitate backwards compatibility
// Overdose is not really needed as many moved properties have changed anyways
var isDefault = Objects.equals(r, def);
if (isDefault && value.isVaultSpecific()) {
if (isDefault) {
loadValue(globalStorageHandler, value);
}
}

View file

@ -7,14 +7,14 @@ import java.nio.file.Path;
public interface GitStorageHandler {
static GitStorageHandler getInstance() {
return (GitStorageHandler) ProcessControlProvider.get().createStorageHandler();
return (GitStorageHandler) ProcessControlProvider.get().getGitStorageHandler();
}
boolean supportsShare();
void init(Path dir);
void init();
void beforeStorageLoad();
void setupRepositoryAndPull();
void afterStorageLoad();

View file

@ -3,7 +3,6 @@ package io.xpipe.app.storage;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.UnlockAlert;
import io.xpipe.core.process.OsType;
import io.xpipe.core.store.LocalStore;
import lombok.Getter;
@ -52,16 +51,6 @@ public class StandardStorage extends DataStorage {
ErrorEvent.fromThrowable(e).terminal(true).build().handle();
}
this.gitStorageHandler.init(dir);
this.gitStorageHandler.beforeStorageLoad();
try {
// This can fail if the necessary platform initialization fails
UnlockAlert.showIfNeeded();
} catch (Exception e) {
ErrorEvent.fromThrowable(e).terminal(true).build().handle();
}
try {
initSystemInfo();
} catch (Exception e) {

View file

@ -28,7 +28,7 @@ public abstract class ProcessControlProvider {
public abstract ShellControl createLocalProcessControl(boolean stoppable);
public abstract Object createStorageHandler();
public abstract Object getGitStorageHandler();
public abstract ShellDialect getEffectiveLocalDialect();