Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
crschnick committed Nov 23, 2024
1 parent 7f85600 commit 04f39cd
Show file tree
Hide file tree
Showing 17 changed files with 22 additions and 39 deletions.
25 changes: 3 additions & 22 deletions app/src/main/java/io/xpipe/app/core/AppCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,7 @@ public static <T> T getNonNull(String key, Class<?> type, Supplier<T> notPresent
return r;
}
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).omit().handle();
FileUtils.deleteQuietly(path.toFile());
}
}
return notPresent != null ? notPresent.get() : null;
}

@SuppressWarnings("unchecked")
public static <T> T getNullable(String key, Class<?> type, Supplier<T> notPresent) {
var path = getPath(key);
if (Files.exists(path)) {
try {
var tree = JsonConfigHelper.readRaw(path);
if (tree.isMissingNode()) {
return notPresent.get();
}

return (T) JacksonMapper.getDefault().treeToValue(tree, type);
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).omit().handle();
ErrorEvent.fromThrowable("Could not parse cached data for key " + key, ex).omit().handle();
FileUtils.deleteQuietly(path.toFile());
}
}
Expand All @@ -100,7 +81,7 @@ public static boolean getBoolean(String key, boolean notPresent) {

return tree.asBoolean();
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).omit().handle();
ErrorEvent.fromThrowable("Could not parse cached data for key " + key, ex).omit().handle();
FileUtils.deleteQuietly(path.toFile());
}
}
Expand All @@ -115,7 +96,7 @@ public static <T> void update(String key, T val) {
var tree = JacksonMapper.getDefault().valueToTree(val);
JsonConfigHelper.writeConfig(path, tree);
} catch (Exception e) {
ErrorEvent.fromThrowable("Could not parse cached data for key " + key, e)
ErrorEvent.fromThrowable("Could not write cache data for key " + key, e)
.omitted(true)
.build()
.handle();
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/io/xpipe/app/util/JsonConfigHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static JsonNode readRaw(Path in) {
.build()
.handle();
} catch (IOException e) {
ErrorEvent.fromThrowable("Unable to parse file " + in, e).build().handle();
ErrorEvent.fromThrowable("Unable to parse file " + in, e).expected().build().handle();
}
return JsonNodeFactory.instance.missingNode();
}
Expand All @@ -52,7 +52,7 @@ public static void writeConfig(Path out, JsonNode node) {
try {
FileUtils.forceMkdirParent(out.toFile());
} catch (IOException e) {
ErrorEvent.fromThrowable(e).build().handle();
ErrorEvent.fromThrowable(e).expected().build().handle();
return;
}

Expand All @@ -63,7 +63,7 @@ public static void writeConfig(Path out, JsonNode node) {
var newContent = writer.toString();
Files.writeString(out, newContent);
} catch (IOException e) {
ErrorEvent.fromThrowable("Unable to write file " + out, e).build().handle();
ErrorEvent.fromThrowable("Unable to write file " + out, e).expected().build().handle();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,17 @@ default void startSessionIfNeeded() throws Exception {
}

try {
setSessionEnabled(true);
s = newSession();
if (s != null) {
setSessionEnabled(true);
s.start();
setCache("session", s);
onStateChange(true);
} else {
setSessionEnabled(false);
}
} catch (Exception ex) {
setSessionEnabled(false);
onStateChange(false);
throw ex;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/changelogs/13.2_incremental.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- Improve license requirement handling for systems. You can now add all systems without a license and also search for available subconnections. Only establishing the actual connection in a terminal or in the file browser will show any license requirement notice. This allows you to check whether all systems and installed tools are correctly recognized before considering purchasing a license.
- Add support for forward and backwards mouse buttons for the file browser navigation
- Fix NullPointer when trying to connect to VM connections created in older XPipe versions
- Fix Local Machine connection entry being able to get deleted from the context menu, causing various Exceptions
- Fix kubectl being wrongly detected in WSL
-
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private class Action implements ActionProvider.Action {
@Override
public void execute() throws Exception {
var sc = shellStore.getStore().getOrStartSession();
sc.checkLicenseOrThrow();
var script = hierarchy.getLeafBase().getStore().assembleScriptChain(sc);
sc.command(script).execute();
}
Expand Down
2 changes: 1 addition & 1 deletion lang/uacc/strings/translations_da.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ upgrade=Opgradering
upgradeTitle=Tilgængelige planer
status=Status
type=Skriv
licenseAlertTitle=Kommerciel brug
licenseAlertTitle=Licens påkrævet
useCommunity=Fortsæt med fællesskab
previewDescription=Afprøv nye funktioner i et par uger efter udgivelsen.
tryPreview=Aktiver forhåndsvisning
Expand Down
2 changes: 1 addition & 1 deletion lang/uacc/strings/translations_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ upgrade=Upgrade
upgradeTitle=Verfügbare Pläne
status=Status
type=Typ
licenseAlertTitle=Kommerzielle Nutzung
licenseAlertTitle=Erforderliche Lizenz
useCommunity=Weiter mit Community
previewDescription=Teste die neuen Funktionen ein paar Wochen lang nach der Veröffentlichung.
tryPreview=Vorschau aktivieren
Expand Down
2 changes: 1 addition & 1 deletion lang/uacc/strings/translations_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ upgrade=Upgrade
upgradeTitle=Available plans
status=Status
type=Type
licenseAlertTitle=Commercial usage
licenseAlertTitle=License required
useCommunity=Continue with community
previewDescription=Try out new features for a couple of weeks after release.
tryPreview=Activate preview
Expand Down
2 changes: 1 addition & 1 deletion lang/uacc/strings/translations_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ upgrade=Actualiza
upgradeTitle=Planes disponibles
status=Estado
type=Escribe
licenseAlertTitle=Uso comercial
licenseAlertTitle=Licencia necesaria
useCommunity=Continuar con la comunidad
previewDescription=Prueba las nuevas funciones durante un par de semanas después del lanzamiento.
tryPreview=Activar vista previa
Expand Down
2 changes: 1 addition & 1 deletion lang/uacc/strings/translations_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ upgrade=Mise à niveau
upgradeTitle=Plans disponibles
status=Statut
type=Type de texte
licenseAlertTitle=Usage commercial
licenseAlertTitle=Licence requise
useCommunity=Continue avec la communauté
previewDescription=Essaie les nouvelles fonctionnalités pendant quelques semaines après leur publication.
tryPreview=Activer l'aperçu
Expand Down
2 changes: 1 addition & 1 deletion lang/uacc/strings/translations_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ upgrade=Aggiornamento
upgradeTitle=Piani disponibili
status=Stato
type=Tipo
licenseAlertTitle=Uso commerciale
licenseAlertTitle=Licenza richiesta
useCommunity=Continua con la comunità
previewDescription=Prova le nuove funzionalità per un paio di settimane dopo il rilascio.
tryPreview=Attiva l'anteprima
Expand Down
2 changes: 1 addition & 1 deletion lang/uacc/strings/translations_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ upgrade=アップグレード
upgradeTitle=利用可能なプラン
status=ステータス
type=タイプ
licenseAlertTitle=商用利用
licenseAlertTitle=ライセンスが必要
useCommunity=コミュニティに続く
previewDescription=リリース後数週間は新機能を試す。
tryPreview=プレビューを有効にする
Expand Down
2 changes: 1 addition & 1 deletion lang/uacc/strings/translations_nl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ upgrade=Upgrade
upgradeTitle=Beschikbare plannen
status=Status
type=Type
licenseAlertTitle=Commercieel gebruik
licenseAlertTitle=Licentie vereist
useCommunity=Verder met gemeenschap
previewDescription=Probeer nieuwe functies een paar weken na de release uit.
tryPreview=Voorbeeld activeren
Expand Down
2 changes: 1 addition & 1 deletion lang/uacc/strings/translations_pt.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ upgrade=Actualiza-te
upgradeTitle=Planos disponíveis
status=Estado
type=Digita
licenseAlertTitle=Utilização comercial
licenseAlertTitle=Licença necessária
useCommunity=Continua com a comunidade
previewDescription=Experimenta as novas funcionalidades durante algumas semanas após o lançamento.
tryPreview=Ativar pré-visualização
Expand Down
2 changes: 1 addition & 1 deletion lang/uacc/strings/translations_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ upgrade=Обновление
upgradeTitle=Доступные планы
status=Статус
type=Тип
licenseAlertTitle=Коммерческое использование
licenseAlertTitle=Требуется лицензия
useCommunity=Продолжайте общаться
previewDescription=Опробуй новые возможности в течение пары недель после релиза.
tryPreview=Активировать предварительный просмотр
Expand Down
2 changes: 1 addition & 1 deletion lang/uacc/strings/translations_tr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ upgrade=Yükseltme
upgradeTitle=Mevcut planlar
status=Durum
type=Tip
licenseAlertTitle=Ticari kullanım
licenseAlertTitle=Lisans gerekli
useCommunity=Topluluk ile devam edin
previewDescription=Yayınlandıktan sonra birkaç hafta boyunca yeni özellikleri deneyin.
tryPreview=Önizlemeyi etkinleştir
Expand Down
2 changes: 1 addition & 1 deletion lang/uacc/strings/translations_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ upgrade=升级
upgradeTitle=可用计划
status=状态
type=类型
licenseAlertTitle=商业用途
licenseAlertTitle=所需许可证
useCommunity=继续社区
previewDescription=新功能发布后试用几周。
tryPreview=激活预览
Expand Down

0 comments on commit 04f39cd

Please sign in to comment.