mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-04-25 08:59:25 -04:00
Various fixes [stage]
This commit is contained in:
@@ -53,7 +53,11 @@ public sealed interface OsType permits OsType.Windows, OsType.Linux, OsType.MacO
|
||||
@Override
|
||||
public List<String> determineInterestingPaths(ShellControl pc) throws Exception {
|
||||
var home = getHomeDirectory(pc);
|
||||
return List.of(home, FileNames.join(home, "Documents"), FileNames.join(home, "Downloads"), FileNames.join(home, "Desktop"));
|
||||
return List.of(
|
||||
home,
|
||||
FileNames.join(home, "Documents"),
|
||||
FileNames.join(home, "Downloads"),
|
||||
FileNames.join(home, "Desktop"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,7 +115,8 @@ public sealed interface OsType permits OsType.Windows, OsType.Linux, OsType.MacO
|
||||
@Override
|
||||
public List<String> determineInterestingPaths(ShellControl pc) throws Exception {
|
||||
var home = getHomeDirectory(pc);
|
||||
return List.of(FileNames.join(home, "Desktop"));
|
||||
return List.of(
|
||||
home, FileNames.join(home, "Downloads"), FileNames.join(home, "Documents"), "/etc", "/tmp", "/var");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -180,7 +185,16 @@ public sealed interface OsType permits OsType.Windows, OsType.Linux, OsType.MacO
|
||||
@Override
|
||||
public List<String> determineInterestingPaths(ShellControl pc) throws Exception {
|
||||
var home = getHomeDirectory(pc);
|
||||
return List.of(FileNames.join(home, "Desktop"));
|
||||
return List.of(
|
||||
home,
|
||||
FileNames.join(home, "Downloads"),
|
||||
FileNames.join(home, "Documents"),
|
||||
FileNames.join(home, "Desktop"),
|
||||
"/Applications",
|
||||
"/Library",
|
||||
"/System",
|
||||
"/etc"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,35 +6,40 @@ import lombok.Getter;
|
||||
public class ProcessOutputException extends Exception {
|
||||
|
||||
public static ProcessOutputException of(String customPrefix, ProcessOutputException ex) {
|
||||
var messageSuffix = ex.getOutput() != null && ! ex.getOutput().isBlank()?": " + ex.getOutput() : "";
|
||||
var messageSuffix = ex.getOutput() != null && !ex.getOutput().isBlank() ? ": " + ex.getOutput() : "";
|
||||
var message = customPrefix + messageSuffix;
|
||||
return new ProcessOutputException(message, ex.getExitCode(), ex.getOutput());
|
||||
}
|
||||
|
||||
public static ProcessOutputException of(int exitCode, String output, String accumulatedError) {
|
||||
var combinedError = (accumulatedError != null ? accumulatedError.trim() + "\n" : "") + (output != null ? output.trim() : "");
|
||||
var message = switch (exitCode) {
|
||||
case CommandControl.KILLED_EXIT_CODE -> "Process timed out (exit code " + exitCode + ") " + combinedError;
|
||||
case CommandControl.TIMEOUT_EXIT_CODE -> "Process timed out (exit code " + exitCode + ") " + combinedError;
|
||||
default -> "Process returned with exit code " + exitCode + ": " + combinedError;
|
||||
};
|
||||
var combinedError = (accumulatedError != null ? accumulatedError.trim() + "\n" : "")
|
||||
+ (output != null ? output.trim() : "");
|
||||
var hasMessage = !combinedError.trim().isEmpty();
|
||||
var errorSuffix = hasMessage ? ": " + combinedError : "";
|
||||
var message =
|
||||
switch (exitCode) {
|
||||
case CommandControl.KILLED_EXIT_CODE -> "Process timed out and had to be killed" + errorSuffix;
|
||||
case CommandControl.TIMEOUT_EXIT_CODE -> "Wait for process exit timed out"
|
||||
+ errorSuffix;
|
||||
default -> "Process returned exit code " + exitCode + errorSuffix;
|
||||
};
|
||||
return new ProcessOutputException(message, exitCode, combinedError);
|
||||
}
|
||||
|
||||
private final int exitCode;
|
||||
private final String output;
|
||||
|
||||
private ProcessOutputException(String message, int exitCode, String output) {
|
||||
private ProcessOutputException(String message, int exitCode, String output) {
|
||||
super(message);
|
||||
this.exitCode = exitCode;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
public boolean isTimeOut() {
|
||||
return exitCode == CommandControl.TIMEOUT_EXIT_CODE;
|
||||
return exitCode == CommandControl.TIMEOUT_EXIT_CODE;
|
||||
}
|
||||
|
||||
public boolean isKill() {
|
||||
return exitCode == CommandControl.KILLED_EXIT_CODE;
|
||||
return exitCode == CommandControl.KILLED_EXIT_CODE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user