Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2e591e5

Browse files
clydegaleclydegaleJohannes Merz
authored
Add ${Name} as variable for save path (#623)
--------- Co-authored-by: clydegale <clydegale@none.com> Co-authored-by: Johannes Merz <johannes.merz@mercedes-benz.com>
1 parent 92d6f1a commit 2e591e5

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

‎src/main/java/airsquared/blobsaver/app/Background.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ public static void saveAllBackgroundBlobs() {
280280
}
281281

282282
public static void saveBlobs(Prefs.SavedDevice savedDevice) {
283-
TSS.Builder builder = new TSS.Builder().setDevice(savedDevice.getIdentifier())
283+
TSS.Builder builder = new TSS.Builder().setName(savedDevice.getName())
284+
.setDevice(savedDevice.getIdentifier())
284285
.setEcid(savedDevice.getEcid()).setSavePath(savedDevice.getSavePath())
285286
.setIncludeBetas(savedDevice.doesIncludeBetas());
286287
savedDevice.getBoardConfig().ifPresent(builder::setBoardConfig);

‎src/main/java/airsquared/blobsaver/app/CLI.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static class BackgroundControls {
9393

9494
@Option(names = "--save-path", paramLabel = "<path>",
9595
description = "Directory to save blobs in. Can use the following variables: " +
96-
"$${DeviceIdentifier}, $${BoardConfig}, $${APNonce}, $${Generator}, $${DeviceModel}, $${ECID}, $${FullVersionString}, $${BuildID}, and $${MajorVersion}.")
96+
"$${DeviceIdentifier}, $${BoardConfig}, $${APNonce}, $${Generator}, $${DeviceModel}, $${ECID}, $${FullVersionString}, $${BuildID}, $${MajorVersion} and $${Name} (if using a saved device).")
9797
File savePath;
9898

9999
@ArgGroup

‎src/main/java/airsquared/blobsaver/app/Controller.java‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public class Controller {
5757

5858
@FXML private TextField ecidField, boardConfigField, apnonceField, generatorField, versionField, identifierField,
5959
pathField, ipswField;
60+
private String deviceName;
6061

6162
@FXML private CheckBox apnonceCheckBox, allSignedVersionsCheckBox, identifierCheckBox, betaCheckBox,
6263
manualURLCheckBox, saveToTSSSaverCheckBox, saveToSHSHHostCheckBox;
@@ -204,6 +205,7 @@ private void loadSavedDevice(Prefs.SavedDevice savedDevice) {
204205
}
205206
deleteDeviceMenu.setText("Remove \"" + savedDevice + "\"");
206207

208+
deviceName = savedDevice.getName();
207209
ecidField.setText(savedDevice.getEcid());
208210
pathField.setText(savedDevice.getSavePath());
209211
if (!betaCheckBox.isDisabled()) {
@@ -324,7 +326,8 @@ public void checkBlobs() {
324326
public void locationHelp() {
325327
ButtonType openURL = new ButtonType("Open URL");
326328
Alert alert = new Alert(Alert.AlertType.INFORMATION,
327-
"You can use the following variables which will be automatically replaced by their respective values: ${DeviceIdentifier}, ${BoardConfig}, ${APNonce}, ${Generator}, ${DeviceModel}, ${ECID}, ${FullVersionString}, ${BuildID}, and ${MajorVersion}." +
329+
"You can use the following variables which will be automatically replaced by their respective values: ${DeviceIdentifier}, ${BoardConfig}, ${APNonce}, ${Generator}, ${DeviceModel}, ${ECID}, ${FullVersionString}, ${BuildID} and ${MajorVersion}." +
330+
"\nIf using a saved device you can also use ${Name}." +
328331
"\n\nExamples: /Users/airsquared/Blobs/${DeviceModel}/${MajorVersion}" +
329332
"\n/Users/airsquared/Blobs/${DeviceIdentifier}/${MajorVersion}/${FullVersionString}\n\n" +
330333
"Click \"Open URL\" to see how to automatically upload blobs you save to the cloud.", openURL, ButtonType.OK);
@@ -655,12 +658,20 @@ private boolean checkInputs() {
655658

656659
private TSS createTSS(String runningAlertTitle) {
657660
TSS.Builder builder = new TSS.Builder()
661+
.setName(deviceName)
658662
.setDevice(identifierCheckBox.isSelected() ?
659663
identifierField.getText() : Devices.modelToIdentifier(deviceModelChoiceBox.getValue()))
660664
.setEcid(ecidField.getText()).setSavePath(pathField.getText())
661665
.setIncludeBetas(betaCheckBox.isSelected())
662666
.saveToTSSSaver(saveToTSSSaverCheckBox.isSelected())
663667
.saveToSHSHHost(saveToSHSHHostCheckBox.isSelected());
668+
if (pathField.getText().contains("${Name}") && deviceName == null) {
669+
final Alert deviceNameAlert = new Alert(Alert.AlertType.WARNING);
670+
deviceNameAlert.setTitle("Warning");
671+
deviceNameAlert.setHeaderText("Warning");
672+
deviceNameAlert.setContentText("You are using ${Name} variable but your device does not have a name yet. Maybe you forgot to save it or did not select it in the list first?");
673+
deviceNameAlert.showAndWait();
674+
}
664675
if (!boardConfigField.isDisabled()) {
665676
builder.setBoardConfig(boardConfigField.getText());
666677
}

‎src/main/java/airsquared/blobsaver/app/TSS.java‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public class TSS extends Task<String> {
5151
private static final Pattern ipswURLPattern = Pattern.compile("(https?://|file:/).*\\.(ipsw|plist)");
5252
private static final Pattern versionPattern = Pattern.compile("[0-9]+\\.[0-9]+\\.?[0-9]*(?<!\\.)");
5353

54+
private final String name;
5455
private final String deviceIdentifier;
5556
private final String ecid;
5657
private final String savePath;
@@ -68,7 +69,8 @@ public class TSS extends Task<String> {
6869
/**
6970
* Private constructor; use {@link TSS.Builder} instead
7071
*/
71-
private TSS(String deviceIdentifier, String ecid, String savePath, String boardConfig, boolean includeBetas, String manualVersion, String manualIpswURL, String apnonce, String generator, boolean saveToTSSSaver, boolean saveToSHSHHost) {
72+
private TSS(String name, String deviceIdentifier, String ecid, String savePath, String boardConfig, boolean includeBetas, String manualVersion, String manualIpswURL, String apnonce, String generator, boolean saveToTSSSaver, boolean saveToSHSHHost) {
73+
this.name = name;
7274
this.deviceIdentifier = deviceIdentifier;
7375
this.ecid = ecid;
7476
this.boardConfig = boardConfig;
@@ -189,7 +191,8 @@ private String parsePath(String input) {
189191
if (!input.contains("${")) return input;
190192
String template = input;
191193

192-
var variables = Map.of("${DeviceIdentifier}", deviceIdentifier,
194+
var variables = Map.of("${Name}", Utils.defIfNull(name, "UnknownName"),
195+
"${DeviceIdentifier}", deviceIdentifier,
193196
"${BoardConfig}", getBoardConfig(),
194197
"${APNonce}", Utils.defIfNull(apnonce, "UnknownAPNonce"),
195198
"${Generator}", Utils.defIfNull(generator, "UnknownGenerator"),
@@ -382,9 +385,13 @@ && containsIgnoreCase(tsscheckerLog, "checking tss status failed")) {
382385

383386
@SuppressWarnings("UnusedReturnValue")
384387
public static class Builder {
385-
private String device, ecid, savePath, boardConfig, manualVersion, manualIpswURL, apnonce, generator;
388+
private String name, device, ecid, savePath, boardConfig, manualVersion, manualIpswURL, apnonce, generator;
386389
private boolean includeBetas, saveToTSSSaver, saveToSHSHHost;
387390

391+
public Builder setName(String name) {
392+
this.name = name;
393+
return this;
394+
}
388395
public Builder setDevice(String device) {
389396
this.device = device;
390397
return this;
@@ -443,7 +450,8 @@ public Builder saveToSHSHHost(boolean saveToSHSHHost) {
443450
}
444451

445452
public TSS build() {
446-
return new TSS(Objects.requireNonNull(device, "Device"),
453+
return new TSS(name,
454+
Objects.requireNonNull(device, "Device"),
447455
Objects.requireNonNull(ecid, "ECID"),
448456
Objects.requireNonNull(savePath, "Save Path"),
449457
boardConfig, includeBetas, manualVersion, manualIpswURL, apnonce, generator, saveToTSSSaver, saveToSHSHHost);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /