mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Improve distribution type initialization
This commit is contained in:
parent
e3265a573d
commit
faed51f996
2 changed files with 18 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue