Skip to content

Commit 1763226

Browse files
Jakub SzczyrkJakub Szczyrk
authored andcommitted
Fix start main executable with offline mode
1 parent 2518da6 commit 1763226

File tree

4 files changed

+45
-4
lines changed

4 files changed

+45
-4
lines changed

Assets/PatchKit Patcher/Scripts/AppData/Local/ILocalMetaData.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,11 @@ public interface ILocalMetaData
4444
void SetProductKey(string productKey);
4545

4646
string GetProductKey();
47+
48+
void SetMainExecutableAndArgs(string mainExecutable, string mainExecutableArgs);
49+
50+
string GetMainExecutable();
51+
52+
string GetMainExecutableArgs();
4753
}
4854
}

Assets/PatchKit Patcher/Scripts/AppData/Local/LocalMetaData.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ private struct Data
4040
[DefaultValue("none")]
4141
[JsonProperty("product_key_encryption", DefaultValueHandling = DefaultValueHandling.Populate)]
4242
public string ProductKeyEncryption;
43+
44+
[JsonProperty("main_executable")]
45+
public string MainExecutable;
46+
47+
[JsonProperty("main_executable_args")]
48+
public string MainExecutableArgs;
4349

4450
[JsonProperty("_fileVersions")] public Dictionary<string, int> FileVersionIds;
4551
}
@@ -174,6 +180,24 @@ public string GetProductKey()
174180
{
175181
return _data.ProductKey;
176182
}
183+
184+
public void SetMainExecutableAndArgs(string mainExecutable, string mainExecutableArgs)
185+
{
186+
_data.MainExecutable = mainExecutable;
187+
_data.MainExecutableArgs = mainExecutableArgs;
188+
189+
SaveData();
190+
}
191+
192+
public string GetMainExecutable()
193+
{
194+
return _data.MainExecutable;
195+
}
196+
197+
public string GetMainExecutableArgs()
198+
{
199+
return _data.MainExecutableArgs;
200+
}
177201

178202
private void CreateDataDir()
179203
{

Assets/PatchKit Patcher/Scripts/AppStarter.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ public AppStarter(App app)
3131
private string ResolveExecutablePath(AppVersion? appVersion)
3232
{
3333
PlatformType platformType = Platform.GetPlatformType();
34-
35-
if (appVersion.HasValue &&
36-
!string.IsNullOrEmpty(appVersion.Value.MainExecutable))
34+
string mainExecutable = (appVersion.HasValue &&
35+
!string.IsNullOrEmpty(appVersion.Value.MainExecutable))
36+
? appVersion.Value.MainExecutable
37+
: _app.LocalMetaData.GetMainExecutable();
38+
39+
if (!string.IsNullOrEmpty(mainExecutable))
3740
{
3841
string executablePath = Path.Combine(
3942
_app.LocalDirectory.Path,
40-
appVersion.Value.MainExecutable);
43+
mainExecutable);
4144

4245
bool isOSXApp = platformType == PlatformType.OSX &&
4346
executablePath.EndsWith(".app") &&
@@ -97,6 +100,10 @@ private void StartAppVersion(AppVersion? appVersion, string customArgs)
97100
{
98101
appArgs += " " + appVersion.Value.MainExecutableArgs;
99102
}
103+
else
104+
{
105+
appArgs += " " + _app.LocalMetaData.GetMainExecutableArgs();
106+
}
100107

101108
if (appFilePath == null)
102109
{

Assets/PatchKit Patcher/Scripts/Patcher.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,10 @@ private void ThreadUpdateApp(bool automatically, CancellationToken cancellationT
899899
{
900900
_appInfo.Value = _app.RemoteMetaData.GetAppInfo(!automatically, _updateAppCancellationTokenSource.Token);
901901
_remoteVersionId.Value = _app.GetLatestVersionId(!automatically, _updateAppCancellationTokenSource.Token);
902+
var latestAppVersion =
903+
_app.RemoteMetaData.GetAppVersionInfo(_remoteVersionId.Value.Value, false, cancellationToken);
904+
_app.LocalMetaData.SetMainExecutableAndArgs(latestAppVersion.MainExecutable, latestAppVersion.MainExecutableArgs);
905+
902906
if (_app.IsFullyInstalled())
903907
{
904908
_localVersionId.Value = _app.GetInstalledVersionId();

0 commit comments

Comments
 (0)