mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 15:40:23 +00:00
Rework git init order
This commit is contained in:
parent
525916d59d
commit
8e5550c61d
5 changed files with 34 additions and 25 deletions
|
@ -10,10 +10,12 @@ import io.xpipe.app.ext.ActionProvider;
|
||||||
import io.xpipe.app.issue.TrackEvent;
|
import io.xpipe.app.issue.TrackEvent;
|
||||||
import io.xpipe.app.prefs.AppPrefs;
|
import io.xpipe.app.prefs.AppPrefs;
|
||||||
import io.xpipe.app.storage.DataStorage;
|
import io.xpipe.app.storage.DataStorage;
|
||||||
|
import io.xpipe.app.storage.GitStorageHandler;
|
||||||
import io.xpipe.app.update.XPipeDistributionType;
|
import io.xpipe.app.update.XPipeDistributionType;
|
||||||
import io.xpipe.app.util.FileBridge;
|
import io.xpipe.app.util.FileBridge;
|
||||||
import io.xpipe.app.util.LicenseProvider;
|
import io.xpipe.app.util.LicenseProvider;
|
||||||
import io.xpipe.app.util.LocalShell;
|
import io.xpipe.app.util.LocalShell;
|
||||||
|
import io.xpipe.app.util.UnlockAlert;
|
||||||
import io.xpipe.core.util.JacksonMapper;
|
import io.xpipe.core.util.JacksonMapper;
|
||||||
|
|
||||||
public class BaseMode extends OperationMode {
|
public class BaseMode extends OperationMode {
|
||||||
|
@ -44,16 +46,19 @@ public class BaseMode extends OperationMode {
|
||||||
JacksonMapper.initModularized(AppExtensionManager.getInstance().getExtendedLayer());
|
JacksonMapper.initModularized(AppExtensionManager.getInstance().getExtendedLayer());
|
||||||
AppI18n.init();
|
AppI18n.init();
|
||||||
LicenseProvider.get().init();
|
LicenseProvider.get().init();
|
||||||
AppPrefs.init();
|
AppPrefs.initLocal();
|
||||||
AppCertutilCheck.check();
|
AppCertutilCheck.check();
|
||||||
AppAvCheck.check();
|
AppAvCheck.check();
|
||||||
LocalShell.init();
|
LocalShell.init();
|
||||||
XPipeDistributionType.init();
|
XPipeDistributionType.init();
|
||||||
AppShellCheck.check();
|
AppShellCheck.check();
|
||||||
AppPrefs.setDefaults();
|
AppPrefs.setDefaults();
|
||||||
// Initialize socket server before storage
|
// Initialize socket server as we should be prepared for git askpass commands
|
||||||
// as we should be prepared for git askpass commands
|
|
||||||
AppSocketServer.init();
|
AppSocketServer.init();
|
||||||
|
GitStorageHandler.getInstance().init();
|
||||||
|
GitStorageHandler.getInstance().setupRepositoryAndPull();
|
||||||
|
AppPrefs.initSharedRemote();
|
||||||
|
UnlockAlert.showIfNeeded();
|
||||||
DataStorage.init();
|
DataStorage.init();
|
||||||
AppFileWatcher.init();
|
AppFileWatcher.init();
|
||||||
FileBridge.init();
|
FileBridge.init();
|
||||||
|
|
|
@ -153,11 +153,14 @@ public class AppPrefs {
|
||||||
categories.get(selected >= 0 && selected < categories.size() ? selected : 0));
|
categories.get(selected >= 0 && selected < categories.size() ? selected : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init() {
|
public static void initLocal() {
|
||||||
INSTANCE = new AppPrefs();
|
INSTANCE = new AppPrefs();
|
||||||
PrefsProvider.getAll().forEach(prov -> prov.addPrefs(INSTANCE.extensionHandler));
|
PrefsProvider.getAll().forEach(prov -> prov.addPrefs(INSTANCE.extensionHandler));
|
||||||
INSTANCE.load();
|
INSTANCE.loadLocal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void initSharedRemote() {
|
||||||
|
INSTANCE.loadSharedRemote();
|
||||||
INSTANCE.encryptAllVaultData.addListener((observableValue, aBoolean, t1) -> {
|
INSTANCE.encryptAllVaultData.addListener((observableValue, aBoolean, t1) -> {
|
||||||
if (DataStorage.get() != null) {
|
if (DataStorage.get() != null) {
|
||||||
DataStorage.get().forceRewrite();
|
DataStorage.get().forceRewrite();
|
||||||
|
@ -417,16 +420,28 @@ public class AppPrefs {
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
private void loadLocal() {
|
||||||
for (Mapping<?> value : mapping) {
|
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();
|
var def = value.getProperty().getValue();
|
||||||
AppPrefsStorageHandler handler = value.isVaultSpecific() ? vaultStorageHandler : globalStorageHandler;
|
var r = loadValue(vaultStorageHandler, value);
|
||||||
var r = loadValue(handler, value);
|
|
||||||
|
|
||||||
// This can be used to facilitate backwards compatibility
|
// 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);
|
var isDefault = Objects.equals(r, def);
|
||||||
if (isDefault && value.isVaultSpecific()) {
|
if (isDefault) {
|
||||||
loadValue(globalStorageHandler, value);
|
loadValue(globalStorageHandler, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,14 @@ import java.nio.file.Path;
|
||||||
public interface GitStorageHandler {
|
public interface GitStorageHandler {
|
||||||
|
|
||||||
static GitStorageHandler getInstance() {
|
static GitStorageHandler getInstance() {
|
||||||
return (GitStorageHandler) ProcessControlProvider.get().createStorageHandler();
|
return (GitStorageHandler) ProcessControlProvider.get().getGitStorageHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean supportsShare();
|
boolean supportsShare();
|
||||||
|
|
||||||
void init(Path dir);
|
void init();
|
||||||
|
|
||||||
void beforeStorageLoad();
|
void setupRepositoryAndPull();
|
||||||
|
|
||||||
void afterStorageLoad();
|
void afterStorageLoad();
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package io.xpipe.app.storage;
|
||||||
import io.xpipe.app.issue.ErrorEvent;
|
import io.xpipe.app.issue.ErrorEvent;
|
||||||
import io.xpipe.app.issue.TrackEvent;
|
import io.xpipe.app.issue.TrackEvent;
|
||||||
import io.xpipe.app.prefs.AppPrefs;
|
import io.xpipe.app.prefs.AppPrefs;
|
||||||
import io.xpipe.app.util.UnlockAlert;
|
|
||||||
import io.xpipe.core.process.OsType;
|
import io.xpipe.core.process.OsType;
|
||||||
import io.xpipe.core.store.LocalStore;
|
import io.xpipe.core.store.LocalStore;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
@ -52,16 +51,6 @@ public class StandardStorage extends DataStorage {
|
||||||
ErrorEvent.fromThrowable(e).terminal(true).build().handle();
|
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 {
|
try {
|
||||||
initSystemInfo();
|
initSystemInfo();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ public abstract class ProcessControlProvider {
|
||||||
|
|
||||||
public abstract ShellControl createLocalProcessControl(boolean stoppable);
|
public abstract ShellControl createLocalProcessControl(boolean stoppable);
|
||||||
|
|
||||||
public abstract Object createStorageHandler();
|
public abstract Object getGitStorageHandler();
|
||||||
|
|
||||||
public abstract ShellDialect getEffectiveLocalDialect();
|
public abstract ShellDialect getEffectiveLocalDialect();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue