mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2026-08-10 16:43:14 +00:00
fix broken hwi installs
This commit is contained in:
@@ -607,7 +607,7 @@ public class AppController implements Initializable {
|
||||
} else {
|
||||
if(usbStatus == null) {
|
||||
usbStatus = new UsbStatusButton();
|
||||
statusBar.getRightItems().add(usbStatus);
|
||||
statusBar.getRightItems().add(0, usbStatus);
|
||||
} else {
|
||||
usbStatus.getItems().remove(0, usbStatus.getItems().size());
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class MainApp extends Application {
|
||||
GlyphFontRegistry.register(new FontAwesome5Brands());
|
||||
|
||||
Mode mode = Config.get().getMode();
|
||||
if(true || mode == null) {
|
||||
if(mode == null) {
|
||||
WelcomeDialog welcomeDialog = new WelcomeDialog(getHostServices());
|
||||
Optional<Mode> optionalMode = welcomeDialog.showAndWait();
|
||||
if(optionalMode.isPresent()) {
|
||||
|
||||
@@ -87,6 +87,16 @@ public class Hwi {
|
||||
|
||||
private synchronized File getHwiExecutable() {
|
||||
File hwiExecutable = Config.get().getHwi();
|
||||
if(hwiExecutable != null && hwiExecutable.exists()) {
|
||||
if(!testHwi(hwiExecutable)) {
|
||||
if(Platform.getCurrent().getPlatformId().toLowerCase().equals("mac")) {
|
||||
deleteDirectory(hwiExecutable.getParentFile());
|
||||
} else {
|
||||
hwiExecutable.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(hwiExecutable == null || !hwiExecutable.exists()) {
|
||||
try {
|
||||
Platform platform = Platform.getCurrent();
|
||||
@@ -147,6 +157,29 @@ public class Hwi {
|
||||
return hwiExecutable;
|
||||
}
|
||||
|
||||
private boolean testHwi(File hwiExecutable) {
|
||||
try {
|
||||
List<String> command = List.of(hwiExecutable.getAbsolutePath(), "enumerate");
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(command);
|
||||
Process process = processBuilder.start();
|
||||
int exitValue = process.waitFor();
|
||||
return exitValue == 0;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean deleteDirectory(File directoryToBeDeleted) {
|
||||
File[] allContents = directoryToBeDeleted.listFiles();
|
||||
if (allContents != null) {
|
||||
for (File file : allContents) {
|
||||
deleteDirectory(file);
|
||||
}
|
||||
}
|
||||
|
||||
return directoryToBeDeleted.delete();
|
||||
}
|
||||
|
||||
public static File newFile(File destinationDir, ZipEntry zipEntry, Set<PosixFilePermission> setFilePermissions) throws IOException {
|
||||
String destDirPath = destinationDir.getCanonicalPath();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user