mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 13:16:44 +00:00
handle drop of manifest files as well
This commit is contained in:
parent
d109eaa654
commit
2c1f591c51
3 changed files with 21 additions and 6 deletions
|
@ -993,7 +993,7 @@ public class AppController implements Initializable {
|
||||||
public void openFile(File file) {
|
public void openFile(File file) {
|
||||||
if(isWalletFile(file)) {
|
if(isWalletFile(file)) {
|
||||||
openWalletFile(file, true);
|
openWalletFile(file, true);
|
||||||
} else if(isSignatureFile(file)) {
|
} else if(isSignatureOrManifestFile(file)) {
|
||||||
verifyDownload(new ActionEvent(file, rootStack));
|
verifyDownload(new ActionEvent(file, rootStack));
|
||||||
} else {
|
} else {
|
||||||
openTransactionFile(file);
|
openTransactionFile(file);
|
||||||
|
|
|
@ -885,7 +885,7 @@ public class AppServices {
|
||||||
for(File file : openFiles) {
|
for(File file : openFiles) {
|
||||||
if(isWalletFile(file)) {
|
if(isWalletFile(file)) {
|
||||||
EventManager.get().post(new RequestWalletOpenEvent(openWindow, file));
|
EventManager.get().post(new RequestWalletOpenEvent(openWindow, file));
|
||||||
} else if(isSignatureFile(file)) {
|
} else if(isSignatureOrManifestFile(file)) {
|
||||||
EventManager.get().post(new RequestVerifyDownloadEvent(openWindow, file));
|
EventManager.get().post(new RequestVerifyDownloadEvent(openWindow, file));
|
||||||
} else {
|
} else {
|
||||||
EventManager.get().post(new RequestTransactionOpenEvent(openWindow, file));
|
EventManager.get().post(new RequestTransactionOpenEvent(openWindow, file));
|
||||||
|
|
|
@ -364,7 +364,7 @@ public class DownloadVerifierDialog extends Dialog<ButtonBar.ButtonData> {
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<File, String> getManifest(File manifest) throws IOException, InvalidManifestException {
|
public static Map<File, String> getManifest(File manifest) throws IOException, InvalidManifestException {
|
||||||
if(manifest.length() > MAX_VALID_MANIFEST_SIZE) {
|
if(manifest.length() > MAX_VALID_MANIFEST_SIZE) {
|
||||||
throw new InvalidManifestException();
|
throw new InvalidManifestException();
|
||||||
}
|
}
|
||||||
|
@ -374,7 +374,7 @@ public class DownloadVerifierDialog extends Dialog<ButtonBar.ButtonData> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<File, String> getManifest(InputStream manifestStream) throws IOException {
|
public static Map<File, String> getManifest(InputStream manifestStream) throws IOException {
|
||||||
Map<File, String> manifest = new HashMap<>();
|
Map<File, String> manifest = new HashMap<>();
|
||||||
|
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(manifestStream, StandardCharsets.UTF_8));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(manifestStream, StandardCharsets.UTF_8));
|
||||||
|
@ -477,8 +477,23 @@ public class DownloadVerifierDialog extends Dialog<ButtonBar.ButtonData> {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSignatureFile(File file) {
|
public static boolean isSignatureOrManifestFile(File file) {
|
||||||
return file != null && file.getName().length() > 4 && SIGNATURE_EXTENSIONS.stream().anyMatch(ext -> file.getName().toLowerCase(Locale.ROOT).endsWith("." + ext));
|
if(file != null) {
|
||||||
|
if(file.getName().length() > 4 && SIGNATURE_EXTENSIONS.stream().anyMatch(ext -> file.getName().toLowerCase(Locale.ROOT).endsWith("." + ext))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(file.getName().toLowerCase(Locale.ROOT).endsWith(".txt")) {
|
||||||
|
try {
|
||||||
|
Map<File, String> manifest = getManifest(file);
|
||||||
|
return !manifest.isEmpty();
|
||||||
|
} catch(Exception e) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Header extends GridPane {
|
private static class Header extends GridPane {
|
||||||
|
|
Loading…
Reference in a new issue