Skip to content

Commit 37763e9

Browse files
committed
verify dropped release file instead of first platform specific release file found
1 parent 80c4f4f commit 37763e9

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

src/main/java/com/sparrowwallet/sparrow/AppController.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package com.sparrowwallet.sparrow;
22

33
import com.beust.jcommander.JCommander;
4-
import com.google.common.base.Charsets;
54
import com.google.common.eventbus.Subscribe;
6-
import com.google.common.io.ByteSource;
75
import com.sparrowwallet.drongo.*;
86
import com.sparrowwallet.drongo.crypto.*;
97
import com.sparrowwallet.drongo.policy.PolicyType;
@@ -1471,6 +1469,7 @@ public void verifyDownload(ActionEvent event) {
14711469
stage.setAlwaysOnTop(true);
14721470
stage.setAlwaysOnTop(false);
14731471
if(event.getSource() instanceof File file) {
1472+
downloadVerifierDialog.setInitialFile(file);
14741473
downloadVerifierDialog.setSignatureFile(file);
14751474
}
14761475
return;

src/main/java/com/sparrowwallet/sparrow/control/DownloadVerifierDialog.java

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public class DownloadVerifierDialog extends Dialog<ButtonBar.ButtonData> {
6262
private static final List<String> ARCHIVE_EXTENSIONS = List.of("zip", "tar.gz", "tar.bz2", "tar.xz", "rar", "7z");
6363

6464
private static final String SPARROW_RELEASE_PREFIX = "sparrow-";
65+
private static final String SPARROW_RELEASE_ALT_PREFIX = "sparrow_";
6566
private static final String SPARROW_SIGNATURE_SUFFIX = "-manifest.txt.asc";
6667
private static final Pattern SPARROW_RELEASE_VERSION = Pattern.compile("[0-9]+(\\.[0-9]+)*");
6768
private static final long MIN_VALID_SPARROW_RELEASE_SIZE = 10 * 1024 * 1024;
@@ -70,6 +71,7 @@ public class DownloadVerifierDialog extends Dialog<ButtonBar.ButtonData> {
7071
private final ObjectProperty<File> manifest = new SimpleObjectProperty<>();
7172
private final ObjectProperty<File> publicKey = new SimpleObjectProperty<>();
7273
private final ObjectProperty<File> release = new SimpleObjectProperty<>();
74+
private final ObjectProperty<File> initial = new SimpleObjectProperty<>();
7375

7476
private final BooleanProperty manifestDisabled = new SimpleBooleanProperty();
7577
private final BooleanProperty publicKeyDisabled = new SimpleBooleanProperty();
@@ -81,7 +83,7 @@ public class DownloadVerifierDialog extends Dialog<ButtonBar.ButtonData> {
8183

8284
private static File lastFileParent;
8385

84-
public DownloadVerifierDialog(File initialSignatureFile) {
86+
public DownloadVerifierDialog(File initialFile) {
8587
final DialogPane dialogPane = getDialogPane();
8688
dialogPane.getStylesheets().add(AppServices.class.getResource("general.css").toExternalForm());
8789
dialogPane.getStylesheets().add(AppServices.class.getResource("dialog.css").toExternalForm());
@@ -223,11 +225,17 @@ public DownloadVerifierDialog(File initialSignatureFile) {
223225
});
224226

225227
release.addListener((observable, oldValue, releaseFile) -> {
228+
if(releaseFile != null) {
229+
initial.set(null);
230+
}
226231
verify();
227232
});
228233

229-
if(initialSignatureFile != null) {
230-
javafx.application.Platform.runLater(() -> signature.set(initialSignatureFile));
234+
if(initialFile != null) {
235+
javafx.application.Platform.runLater(() -> {
236+
initial.set(initialFile);
237+
signature.set(initialFile);
238+
});
231239
}
232240
}
233241

@@ -455,7 +463,8 @@ private File findSignatureFile(File providedFile) {
455463
}
456464
}
457465

458-
if(providedFile.getName().toLowerCase(Locale.ROOT).startsWith(SPARROW_RELEASE_PREFIX)) {
466+
String providedName = providedFile.getName().toLowerCase(Locale.ROOT);
467+
if(providedName.startsWith(SPARROW_RELEASE_PREFIX) || providedName.startsWith(SPARROW_RELEASE_ALT_PREFIX)) {
459468
Matcher matcher = SPARROW_RELEASE_VERSION.matcher(providedFile.getName());
460469
if(matcher.find()) {
461470
String version = matcher.group();
@@ -482,6 +491,15 @@ private File findManifestFile(File providedFile) {
482491
}
483492

484493
private File findReleaseFile(File manifestFile, Map<File, String> manifestMap) {
494+
File initialFile = initial.get();
495+
if(initialFile != null) {
496+
for(File file : manifestMap.keySet()) {
497+
if(initialFile.getName().equals(file.getName())) {
498+
return initialFile;
499+
}
500+
}
501+
}
502+
485503
List<String> releaseExtensions = getReleaseFileExtensions();
486504
List<List<String>> extensionLists = List.of(releaseExtensions, DISK_IMAGE_EXTENSIONS, ARCHIVE_EXTENSIONS, List.of(""));
487505

@@ -565,7 +583,7 @@ public static boolean isVerifyDownloadFile(File file) {
565583
}
566584
}
567585

568-
if(name.startsWith(SPARROW_RELEASE_PREFIX) && file.length() >= MIN_VALID_SPARROW_RELEASE_SIZE) {
586+
if((name.startsWith(SPARROW_RELEASE_PREFIX) || name.startsWith(SPARROW_RELEASE_ALT_PREFIX)) && file.length() >= MIN_VALID_SPARROW_RELEASE_SIZE) {
569587
Matcher matcher = SPARROW_RELEASE_VERSION.matcher(name);
570588
return matcher.find();
571589
}
@@ -578,6 +596,10 @@ public void setSignatureFile(File signatureFile) {
578596
signature.set(signatureFile);
579597
}
580598

599+
public void setInitialFile(File initialFile) {
600+
initial.set(initialFile);
601+
}
602+
581603
private static class Header extends GridPane {
582604
public Header() {
583605
setMaxWidth(Double.MAX_VALUE);

0 commit comments

Comments
 (0)