fix: Epic client imports get the launch command, versioned installs need a matching manifest build

Games the Epic client installed now carry their LaunchCommand arguments too, split by a new launch.split op. A doubled quote inside a quoted argument is one literal quote, and an install with a version ignores a manifest without the same build.
This commit is contained in:
maxjivi05 authored and MaxsTechReview committed 2026-10-23 23:59:37 -04:00
1 parent 42026b382f
commit b0e405ebf3
4 files changed
+20 -4

No files matched your search

@@ -251,7 +251,7 @@ internal object EpicClientLibrary {
SessionPrefs.addedGameStoredAppId(app, oldFolder.path)?.let { SteamLiveShortcuts.remove(app, it) }
changed = true
}
val next = StoreGameSidecar(
val next = withLaunchArgs(StoreGameSidecar(
Store.EPIC, appName, item.optString("DisplayName").ifEmpty { appName }, exe,
installVersion = item.optString("AppVersionString"), installedAt = existing?.installedAt?.takeIf { it > 0 } ?: folder.lastModified(),
cover = existing?.cover, hero = existing?.hero,
@@ -260,7 +260,7 @@ internal object EpicClientLibrary {
epic = existing?.epic ?: com.droiddeck.launcher.stores.EpicOptions(),
cloud = existing?.cloud ?: true,
launcher = StoreLaunch.LAUNCHER,
)
), commandArgs(item.optString("LaunchCommand")))
val sidecarChanged = existing?.toJson()?.toString(2) != next.toJson().toString(2)
val launcher = File(folder, StoreLaunch.LAUNCHER)
if (sidecarChanged || runCatching { launcher.readText() }.getOrNull() != StoreLaunch.launcherText(next)) {
@@ -328,6 +328,7 @@ internal object EpicClientLibrary {
.put("CatalogItemId", record.optString("itemId"))
.put("InstallLocation", dir)
.put("LaunchExecutable", record.optString("launchExecutable"))
.put("LaunchCommand", record.optString("launchCommand"))
.put("AppVersionString", record.optString("version"))
.put("SidecarDeploymentId", record.optJSONObject("sidecar")?.optString("deploymentId").orEmpty())
.put("DisplayName", title?.takeIf(String::isNotBlank) ?: dir.substringAfterLast('/'))
@@ -386,11 +387,17 @@ internal object EpicClientLibrary {
val manifest = File(install.folder, ".egstore/$guid.manifest").takeIf { it.isFile } ?: return null
val launch = EpicNative.inspect(manifest.readBytes(), JSONObject().put("op", "launch")) ?: return null
val build = launch.optString("buildVersion")
if (install.version.isNotEmpty() && build.isNotEmpty() && build != install.version) return null
if (install.version.isNotEmpty() && build != install.version) return null
val args = launch.optJSONArray("args") ?: return null
return List(args.length()) { args.optString(it) }.filter { it.isNotEmpty() }
}
private fun commandArgs(command: String): List<String> {
if (command.isBlank()) return emptyList()
val args = EpicNative.call("launch.split", JSONObject().put("command", command))?.optJSONArray("args") ?: return emptyList()
return List(args.length()) { args.optString(it) }.filter { it.isNotEmpty() }
}
internal fun withLaunchArgs(sidecar: StoreGameSidecar, args: List<String>): StoreGameSidecar {
val previous = sidecar.extra[LAUNCH_ARGS]?.split('\n')?.filter { it.isNotEmpty() }.orEmpty()
val kept = sidecar.args.filterNot { it in previous }
+1
View File
@@ -160,6 +160,7 @@ synchronous on the calling thread (network calls block: call them off the main t
| `cloud.list` | `accessToken`, `accountId`, `appName` | `files[]` of `name`, `modified` (ms, -1 unknown), `hash`, `readLink` |
| `cloud.writeLinks` | `accessToken`, `accountId`, `appName`, `names[]` | `links`: name → write link |
| `launch.args` | `displayName`, `accountId`, `namespace`, `locale`, `appName`, `deploymentId`, `additional` | `args[]` |
| `launch.split` | `command` | `args[]` |
| `locale` | `language`, `region` | `key`, `tags[]`, `launchLocale` |
`nativeFetch` ops: `manifest.download` (`info`, optional `cdns`) → the manifest bytes;
+6 -1
View File
@@ -45,7 +45,8 @@ pub fn split_command(command: &str) -> Vec<String> {
let mut quoted = false;
let mut started = false;
let mut slashes = 0usize;
for c in command.chars().map(|c| if c == '\t' { ' ' } else { c }).filter(|&c| c >= ' ' && c != '\u{7f}') {
let mut chars = command.chars().map(|c| if c == '\t' { ' ' } else { c }).filter(|&c| c >= ' ' && c != '\u{7f}').peekable();
while let Some(c) = chars.next() {
if c == '\\' {
slashes += 1;
started = true;
@@ -55,6 +56,9 @@ pub fn split_command(command: &str) -> Vec<String> {
current.extend(std::iter::repeat('\\').take(slashes / 2));
if slashes % 2 == 1 {
current.push('"');
} else if quoted && chars.peek() == Some(&'"') {
chars.next();
current.push('"');
} else {
quoted = !quoted;
}
@@ -97,6 +101,7 @@ mod tests {
split_command(r#"-name="a\" b" -dir=C:\Games\ "-q=\\" -r"#),
vec![r#"-name=a" b"#, r"-dir=C:\Games\", r"-q=\", "-r"]
);
assert_eq!(split_command("-name=\"a\"\" b\" -s=\"\"\""), vec!["-name=a\" b", "-s=\""]);
assert!(split_command(" ").is_empty());
}
@@ -113,6 +113,7 @@ fn dispatch(op: &str, req: &Value) -> Value {
};
json!({ "args": launch::arguments(&data) })
}
"launch.split" => json!({ "args": launch::split_command(str_of(req, "command")) }),
"locale" => {
let key = locale::language_key(str_of(req, "language"), str_of(req, "region"));
json!({ "key": key, "tags": locale::tags_for_key(key), "launchLocale": locale::launch_locale(key) })
@@ -192,6 +193,8 @@ mod tests {
assert!(v["error"].is_string());
let v: Value = serde_json::from_str(&call("launch.args", r#"{"namespace":"ns","appName":"A"}"#)).unwrap();
assert_eq!(v["args"][0], "-EpicPortal");
let v: Value = serde_json::from_str(&call("launch.split", r#"{"command":"-PCStore=EGS \"-log=a b.txt\""}"#)).unwrap();
assert_eq!(v["args"], json!(["-PCStore=EGS", "-log=a b.txt"]));
}
#[test]