Skip to content

Commit

Permalink
added ${Name} as variable for save path (CLI only)
Browse files Browse the repository at this point in the history
  • Loading branch information
clydegale authored and Johannes Merz committed Sep 21, 2023
1 parent d385dc3 commit 85b3367
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/main/java/airsquared/blobsaver/app/Background.java
Expand Up @@ -280,7 +280,8 @@ public static void saveAllBackgroundBlobs() {
}

public static void saveBlobs(Prefs.SavedDevice savedDevice) {
TSS.Builder builder = new TSS.Builder().setDevice(savedDevice.getIdentifier())
TSS.Builder builder = new TSS.Builder().setName(savedDevice.getName())
.setDevice(savedDevice.getIdentifier())
.setEcid(savedDevice.getEcid()).setSavePath(savedDevice.getSavePath())
.setIncludeBetas(savedDevice.doesIncludeBetas());
savedDevice.getBoardConfig().ifPresent(builder::setBoardConfig);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/airsquared/blobsaver/app/CLI.java
Expand Up @@ -93,7 +93,7 @@ static class BackgroundControls {

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

@ArgGroup
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/airsquared/blobsaver/app/TSS.java
Expand Up @@ -51,6 +51,7 @@ public class TSS extends Task<String> {
private static final Pattern ipswURLPattern = Pattern.compile("(https?://|file:/).*\\.(ipsw|plist)");
private static final Pattern versionPattern = Pattern.compile("[0-9]+\\.[0-9]+\\.?[0-9]*(?<!\\.)");

private final String name;
private final String deviceIdentifier;
private final String ecid;
private final String savePath;
Expand All @@ -68,7 +69,8 @@ public class TSS extends Task<String> {
/**
* Private constructor; use {@link TSS.Builder} instead
*/
private TSS(String deviceIdentifier, String ecid, String savePath, String boardConfig, boolean includeBetas, String manualVersion, String manualIpswURL, String apnonce, String generator, boolean saveToTSSSaver, boolean saveToSHSHHost) {
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) {
this.name = name;
this.deviceIdentifier = deviceIdentifier;
this.ecid = ecid;
this.boardConfig = boardConfig;
Expand Down Expand Up @@ -189,7 +191,8 @@ private String parsePath(String input) {
if (!input.contains("${")) return input;
String template = input;

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

@SuppressWarnings("UnusedReturnValue")
public static class Builder {
private String device, ecid, savePath, boardConfig, manualVersion, manualIpswURL, apnonce, generator;
private String name, device, ecid, savePath, boardConfig, manualVersion, manualIpswURL, apnonce, generator;
private boolean includeBetas, saveToTSSSaver, saveToSHSHHost;

public Builder setName(String name) {
this.name = name;
return this;
}
public Builder setDevice(String device) {
this.device = device;
return this;
Expand Down Expand Up @@ -443,7 +450,8 @@ public Builder saveToSHSHHost(boolean saveToSHSHHost) {
}

public TSS build() {
return new TSS(Objects.requireNonNull(device, "Device"),
return new TSS(name,
Objects.requireNonNull(device, "Device"),
Objects.requireNonNull(ecid, "ECID"),
Objects.requireNonNull(savePath, "Save Path"),
boardConfig, includeBetas, manualVersion, manualIpswURL, apnonce, generator, saveToTSSSaver, saveToSHSHHost);
Expand Down

0 comments on commit 85b3367

Please sign in to comment.