Skip to content

Commit

Permalink
Rework shell license check
Browse files Browse the repository at this point in the history
  • Loading branch information
crschnick committed Nov 21, 2024
1 parent 3211896 commit 66b6fae
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 13 deletions.
3 changes: 0 additions & 3 deletions app/src/main/java/io/xpipe/app/ext/ShellStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ default ShellControl getOrStartSession() throws Exception {
default ShellSession newSession() throws Exception {
var func = shellFunction();
var c = func.control();
if (!isInStorage()) {
c.withoutLicenseCheck();
}
return new ShellSession(this, () -> c);
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/io/xpipe/app/storage/DataStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,6 @@ public DataStoreEntry getStoreEntry(UUID id) {
}

public DataStoreEntry local() {
return getStoreEntryIfPresent(LOCAL_ID).orElse(null);
return getStoreEntryIfPresent(LOCAL_ID).orElseThrow(() -> new IllegalStateException("Missing local machine connection"));
}
}
1 change: 0 additions & 1 deletion app/src/main/java/io/xpipe/app/util/LocalShell.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public static ShellControl getLocalPowershell() throws Exception {
localPowershell = ProcessControlProvider.get()
.createLocalProcessControl(false)
.subShell(ShellDialects.POWERSHELL)
.withoutLicenseCheck()
.start();
} catch (ProcessOutputException ex) {
throw ProcessOutputException.withPrefix("Failed to start local powershell process", ex);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/io/xpipe/app/util/ScanDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private void onUpdate(DataStoreEntryRef<ShellStore> newValue, StackPane stackPan

ThreadHelper.runFailableAsync(() -> {
BooleanScope.executeExclusive(busy, () -> {
var sc = entry.get().getStore().getOrStartSession().withoutLicenseCheck();
var sc = entry.get().getStore().getOrStartSession();
var a = applicable.apply(entry.get().get(), sc);
Platform.runLater(() -> {
if (a == null) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/io/xpipe/core/process/ShellControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ default boolean canHaveSubshells() {

ShellControl getMachineRootSession();

ShellControl withoutLicenseCheck();

String getOsName();

boolean isLicenseCheck();
Expand Down Expand Up @@ -106,6 +104,8 @@ default <T extends ShellStoreState> ShellControl withShellStateFail(StatefulData

ShellControl withErrorFormatter(Function<String, String> formatter);

void checkLicenseOrThrow();

String prepareIntermediateTerminalOpen(
TerminalInitFunction content, TerminalInitScriptConfig config, WorkingDirectoryFunction workingDirectory)
throws Exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,6 @@ public ShellControl getMachineRootSession() {
return parent.getMachineRootSession();
}

@Override
public ShellControl withoutLicenseCheck() {
return parent.withoutLicenseCheck();
}

@Override
public String getOsName() {
return parent.getOsName();
Expand Down Expand Up @@ -262,6 +257,11 @@ public ShellControl withErrorFormatter(Function<String, String> formatter) {
return parent.withErrorFormatter(formatter);
}

@Override
public void checkLicenseOrThrow() {
parent.checkLicenseOrThrow();
}

@Override
public String prepareIntermediateTerminalOpen(
TerminalInitFunction content, TerminalInitScriptConfig config, WorkingDirectoryFunction workingDirectory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public FileSystem open() throws Exception {
"Shell has a PTY allocated and as a result does not support file system operations");
}

shellControl.checkLicenseOrThrow();

return this;
}

Expand Down

0 comments on commit 66b6fae

Please sign in to comment.