mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-04-26 01:17:52 -04:00
Update fixes
This commit is contained in:
@@ -129,16 +129,26 @@ public class StoreEntryWrapper implements StorageFilter.Filterable {
|
||||
|
||||
var defaultProvider = ActionProvider.ALL.stream()
|
||||
.filter(e -> e.getDefaultDataStoreCallSite() != null
|
||||
&& e.getDefaultDataStoreCallSite().isApplicable(entry.getStore().asNeeded()))
|
||||
.findFirst().map(ActionProvider::getDefaultDataStoreCallSite).orElse(null);
|
||||
&& e.getDefaultDataStoreCallSite()
|
||||
.getApplicableClass()
|
||||
.isAssignableFrom(entry.getStore().getClass())
|
||||
&& e.getDefaultDataStoreCallSite()
|
||||
.isApplicable(entry.getStore().asNeeded()))
|
||||
.findFirst()
|
||||
.map(ActionProvider::getDefaultDataStoreCallSite)
|
||||
.orElse(null);
|
||||
this.defaultActionProvider.setValue(defaultProvider);
|
||||
|
||||
try {
|
||||
actionProviders
|
||||
.get(dataStoreActionProvider)
|
||||
.set(dataStoreActionProvider
|
||||
.getDataStoreCallSite()
|
||||
.isApplicable(entry.getStore().asNeeded()));
|
||||
.getDataStoreCallSite()
|
||||
.getApplicableClass()
|
||||
.isAssignableFrom(entry.getStore().getClass())
|
||||
&& dataStoreActionProvider
|
||||
.getDataStoreCallSite()
|
||||
.isApplicable(entry.getStore().asNeeded()));
|
||||
} catch (Exception ex) {
|
||||
ErrorEvent.fromThrowable(ex).handle();
|
||||
actionProviders.get(dataStoreActionProvider).set(false);
|
||||
|
||||
@@ -36,50 +36,73 @@ public class AppDownloads {
|
||||
return repository;
|
||||
}
|
||||
|
||||
public static Path downloadInstaller(AppInstaller.InstallerAssetType iAsset, String version) throws Exception {
|
||||
var release = AppDownloads.getRelease(version);
|
||||
var asset = release.orElseThrow().listAssets().toList().stream()
|
||||
.filter(ghAsset -> iAsset.isCorrectAsset(ghAsset.getName()))
|
||||
.findAny();
|
||||
|
||||
var url = new URL(asset.get().getBrowserDownloadUrl());
|
||||
var bytes = HttpHelper.executeGet(url, aFloat -> {});
|
||||
var downloadFile =
|
||||
FileUtils.getTempDirectory().toPath().resolve(asset.get().getName());
|
||||
Files.write(downloadFile, bytes);
|
||||
|
||||
TrackEvent.withInfo("installation", "Downloaded asset")
|
||||
.tag("version", version)
|
||||
.tag("url", url)
|
||||
.tag("size", FileUtils.byteCountToDisplaySize(bytes.length))
|
||||
.tag("target", downloadFile)
|
||||
.handle();
|
||||
|
||||
return downloadFile;
|
||||
}
|
||||
|
||||
public static Optional<String> downloadChangelog(String version) throws Exception {
|
||||
var release = AppDownloads.getRelease(version);
|
||||
var asset = release.orElseThrow().listAssets().toList().stream()
|
||||
.filter(ghAsset -> ghAsset.getName().equals("changelog.md"))
|
||||
.findAny();
|
||||
|
||||
if (asset.isEmpty()) {
|
||||
public static Optional<Path> downloadInstaller(
|
||||
AppInstaller.InstallerAssetType iAsset, String version, boolean omitErrors) {
|
||||
var release = AppDownloads.getRelease(version, omitErrors);
|
||||
if (release.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
var url = new URL(asset.get().getBrowserDownloadUrl());
|
||||
var bytes = HttpHelper.executeGet(url, aFloat -> {});
|
||||
return Optional.of(new String(bytes, StandardCharsets.UTF_8));
|
||||
try {
|
||||
var asset = release.orElseThrow().listAssets().toList().stream()
|
||||
.filter(ghAsset -> iAsset.isCorrectAsset(ghAsset.getName()))
|
||||
.findAny();
|
||||
if (asset.isEmpty()) {
|
||||
ErrorEvent.fromMessage("No matching asset found for " + iAsset.getExtension());
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
var url = new URL(asset.get().getBrowserDownloadUrl());
|
||||
var bytes = HttpHelper.executeGet(url, aFloat -> {});
|
||||
var downloadFile =
|
||||
FileUtils.getTempDirectory().toPath().resolve(asset.get().getName());
|
||||
Files.write(downloadFile, bytes);
|
||||
|
||||
TrackEvent.withInfo("installation", "Downloaded asset")
|
||||
.tag("version", version)
|
||||
.tag("url", url)
|
||||
.tag("size", FileUtils.byteCountToDisplaySize(bytes.length))
|
||||
.tag("target", downloadFile)
|
||||
.handle();
|
||||
|
||||
return Optional.of(downloadFile);
|
||||
} catch (Throwable t) {
|
||||
ErrorEvent.fromThrowable(t).omitted(omitErrors).handle();
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getLatestVersion() {
|
||||
return getLatestSuitableRelease()
|
||||
public static Optional<String> downloadChangelog(String version, boolean omitErrors) {
|
||||
var release = AppDownloads.getRelease(version, omitErrors);
|
||||
if (release.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
try {
|
||||
var asset = release.get().listAssets().toList().stream()
|
||||
.filter(ghAsset -> ghAsset.getName().equals("changelog.md"))
|
||||
.findAny();
|
||||
|
||||
if (asset.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
var url = new URL(asset.get().getBrowserDownloadUrl());
|
||||
var bytes = HttpHelper.executeGet(url, aFloat -> {});
|
||||
return Optional.of(new String(bytes, StandardCharsets.UTF_8));
|
||||
} catch (Throwable t) {
|
||||
ErrorEvent.fromThrowable(t).omitted(omitErrors).handle();
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getLatestVersion(boolean omitErrors) {
|
||||
return getLatestSuitableRelease(omitErrors)
|
||||
.map(ghRelease -> ghRelease.getTagName())
|
||||
.orElse("?");
|
||||
}
|
||||
|
||||
public static Optional<GHRelease> getLatestSuitableRelease() {
|
||||
public static Optional<GHRelease> getLatestSuitableRelease(boolean omitErrors) {
|
||||
try {
|
||||
var repo = getRepository();
|
||||
|
||||
@@ -90,17 +113,17 @@ public class AppDownloads {
|
||||
|
||||
return Optional.ofNullable(repo.getLatestRelease());
|
||||
} catch (IOException e) {
|
||||
ErrorEvent.fromThrowable(e).omit().handle();
|
||||
ErrorEvent.fromThrowable("Unable to fetch latest release information", e).omitted(omitErrors).handle();
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<GHRelease> getRelease(String version) {
|
||||
public static Optional<GHRelease> getRelease(String version, boolean omitErrors) {
|
||||
try {
|
||||
var repo = getRepository();
|
||||
return Optional.ofNullable(repo.getReleaseByTagName(version));
|
||||
} catch (IOException e) {
|
||||
ErrorEvent.fromThrowable(e).omit().handle();
|
||||
ErrorEvent.fromThrowable(e).omitted(omitErrors).handle();
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,12 @@ public class AppInstaller {
|
||||
|
||||
public static void installOnRemoteMachine(ShellControl s, String version) throws Exception {
|
||||
var asset = getSuitablePlatformAsset(s);
|
||||
var file = AppDownloads.downloadInstaller(asset, version);
|
||||
installFile(s, asset, file);
|
||||
var file = AppDownloads.downloadInstaller(asset, version, false);
|
||||
if (file.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
installFile(s, asset, file.get());
|
||||
}
|
||||
|
||||
public static void installFileLocal(InstallerAssetType asset, Path localFile) throws Exception {
|
||||
@@ -196,12 +200,20 @@ public class AppInstaller {
|
||||
|
||||
@Override
|
||||
public void installLocal(String file) throws Exception {
|
||||
var command = String.format("""
|
||||
set -x
|
||||
DEBIAN_FRONTEND=noninteractive sudo apt-get remove -qy xpipe
|
||||
DEBIAN_FRONTEND=noninteractive sudo apt-get install -qy "%s"
|
||||
xpipe open
|
||||
""", file);
|
||||
var command = String.format(
|
||||
"""
|
||||
#!/bin/bash
|
||||
|
||||
exec || read -rsp "Update failed ..." -n 1 key
|
||||
|
||||
function exec {
|
||||
set -x
|
||||
DEBIAN_FRONTEND=noninteractive sudo apt-get remove -qy xpipe || return 1
|
||||
DEBIAN_FRONTEND=noninteractive sudo apt-get install -qy "%s" || return 1
|
||||
xpipe open || return 1
|
||||
}
|
||||
""",
|
||||
file);
|
||||
TerminalHelper.open("X-Pipe Updater", command);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,13 +168,17 @@ public class AppUpdater {
|
||||
event("Performing update download ...");
|
||||
try {
|
||||
var downloadFile = AppDownloads.downloadInstaller(
|
||||
lastUpdateCheckResult.getValue().getAssetType(), lastUpdateCheckResult.getValue().version);
|
||||
var changelogString = AppDownloads.downloadChangelog(lastUpdateCheckResult.getValue().version);
|
||||
lastUpdateCheckResult.getValue().getAssetType(), lastUpdateCheckResult.getValue().version, false);
|
||||
if (downloadFile.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var changelogString = AppDownloads.downloadChangelog(lastUpdateCheckResult.getValue().version, false);
|
||||
var changelog = changelogString.orElse(null);
|
||||
var rel = new DownloadedUpdate(
|
||||
AppProperties.get().getVersion(),
|
||||
lastUpdateCheckResult.getValue().version,
|
||||
downloadFile,
|
||||
downloadFile.get(),
|
||||
changelog,
|
||||
lastUpdateCheckResult.getValue().getAssetType());
|
||||
downloadedUpdate.setValue(rel);
|
||||
@@ -249,7 +253,7 @@ public class AppUpdater {
|
||||
}
|
||||
|
||||
try (var ignored = new BusyProperty(busy)) {
|
||||
var rel = AppDownloads.getLatestSuitableRelease();
|
||||
var rel = AppDownloads.getLatestSuitableRelease(!forceCheck);
|
||||
event("Determined latest suitable release "
|
||||
+ rel.map(GHRelease::getName).orElse(null));
|
||||
lastUpdateCheckResult.setValue(null);
|
||||
|
||||
@@ -7,7 +7,11 @@ import javafx.scene.control.Alert;
|
||||
public class UpdateAvailableAlert {
|
||||
|
||||
public static void showIfNeeded() {
|
||||
if (!AppUpdater.get().isDownloadedUpdateStillLatest()) {
|
||||
if (AppUpdater.get().getDownloadedUpdate().getValue() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (AppUpdater.get().getDownloadedUpdate().getValue() != null && !AppUpdater.get().isDownloadedUpdateStillLatest()) {
|
||||
AppUpdater.get().getDownloadedUpdate().setValue(null);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ProxyManagerProviderImpl extends ProxyManagerProvider {
|
||||
|
||||
@Override
|
||||
public Optional<String> checkCompatibility(ShellControl s) throws Exception {
|
||||
var version = ModuleHelper.isImage() ? AppProperties.get().getVersion() : AppDownloads.getLatestVersion();
|
||||
var version = ModuleHelper.isImage() ? AppProperties.get().getVersion() : AppDownloads.getLatestVersion(true);
|
||||
|
||||
if (AppPrefs.get().developerDisableConnectorInstallationVersionCheck().get()) {
|
||||
return Optional.of(AppI18n.get("versionCheckOverride"));
|
||||
@@ -59,7 +59,7 @@ public class ProxyManagerProviderImpl extends ProxyManagerProvider {
|
||||
if (message.isPresent()) {
|
||||
if (showAlert()) {
|
||||
var version =
|
||||
ModuleHelper.isImage() ? AppProperties.get().getVersion() : AppDownloads.getLatestVersion();
|
||||
ModuleHelper.isImage() ? AppProperties.get().getVersion() : AppDownloads.getLatestVersion(true);
|
||||
AppInstaller.installOnRemoteMachine(s, version);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,6 @@ public class Deobfuscator {
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Deobfuscation failed");
|
||||
ex.printStackTrace();
|
||||
return stackTrace;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user