mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-04-24 16:40:58 -04:00
Improve distribution type initialization
This commit is contained in:
@@ -6,6 +6,7 @@ import io.xpipe.app.core.*;
|
||||
import io.xpipe.app.issue.*;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.app.storage.DataStorage;
|
||||
import io.xpipe.app.update.XPipeDistributionType;
|
||||
import io.xpipe.app.util.LicenseProvider;
|
||||
import io.xpipe.app.util.FileBridge;
|
||||
import io.xpipe.app.util.LockedSecretValue;
|
||||
@@ -47,6 +48,7 @@ public class BaseMode extends OperationMode {
|
||||
LicenseProvider.get().init();
|
||||
AppAntivirusAlert.showIfNeeded();
|
||||
LocalStore.init();
|
||||
XPipeDistributionType.init();
|
||||
AppPrefs.init();
|
||||
AppCharsets.init();
|
||||
AppCharsetter.init();
|
||||
|
||||
@@ -30,13 +30,14 @@ public enum XPipeDistributionType {
|
||||
this.updateHandlerSupplier = updateHandlerSupplier;
|
||||
}
|
||||
|
||||
public static XPipeDistributionType get() {
|
||||
public static void init() {
|
||||
if (type != null) {
|
||||
return type;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ModuleHelper.isImage()) {
|
||||
return (type = DEVELOPMENT);
|
||||
type = DEVELOPMENT;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!XPipeSession.get().isNewBuildSession()) {
|
||||
@@ -47,19 +48,29 @@ public enum XPipeDistributionType {
|
||||
.findAny()
|
||||
.orElse(null);
|
||||
if (cachedType != null) {
|
||||
return (type = cachedType);
|
||||
type = cachedType;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var det = determine();
|
||||
|
||||
// Don't cache unknown type
|
||||
if (det == UNKNOWN) {
|
||||
return UNKNOWN;
|
||||
return;
|
||||
}
|
||||
|
||||
type = det;
|
||||
AppCache.update("dist", type.getId());
|
||||
TrackEvent.withInfo("Determined distribution type").tag("type",type.getId()).handle();
|
||||
}
|
||||
|
||||
public static XPipeDistributionType get() {
|
||||
if (type == null) {
|
||||
TrackEvent.withWarn("Distribution type requested before init").handle();
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user