Skip to content

Commit 7a9c7e8

Browse files
committed
Extra logging for IDPS
1 parent 6778b01 commit 7a9c7e8

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

Refresher/Accessors/ConsolePatchAccessor.cs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class ConsolePatchAccessor : PatchAccessor, IDisposable
1010
private readonly FtpClient _client;
1111
private const string BasePath = "/dev_hdd0/";
1212

13-
public Lazy<byte[]> IdpsFile;
13+
public readonly Lazy<byte[]?> IdpsFile;
1414

1515
public ConsolePatchAccessor(string remoteIp)
1616
{
@@ -21,18 +21,37 @@ public ConsolePatchAccessor(string remoteIp)
2121
FtpProfile? profile = this._client.AutoConnect();
2222
if (profile == null) throw new FTPConnectionFailureException();
2323

24-
this.IdpsFile = new Lazy<byte[]>(() =>
24+
this.IdpsFile = new Lazy<byte[]?>(() =>
2525
{
26+
Program.Log("Getting IDPS...", "IDPS");
2627
UriBuilder idpsPs3 = new("http", remoteIp, 80, "idps.ps3");
2728
UriBuilder idpsHex = new("http", remoteIp, 80, "dev_hdd0/idps.hex");
2829

2930
HttpClient httpClient = new();
3031

31-
//Get the /idps.ps3 path, this creates the idps.hex file we can grab.
32-
_ = httpClient.GetAsync(idpsPs3.Uri).Result;
32+
// Get the /idps.ps3 path, this creates the idps.hex file we can grab.
33+
Program.Log(" Triggering generation of IDPS file", "IDPS");
34+
HttpResponseMessage response = httpClient.GetAsync(idpsPs3.Uri).Result;
35+
Program.Log($" {response.StatusCode} {(int)response.StatusCode} (success: {response.IsSuccessStatusCode})", "IDPS");
36+
if (!response.IsSuccessStatusCode)
37+
{
38+
Program.Log("Couldn't fetch the IDPS from the PS3 because of a bad status code.", "IDPS", BreadcrumbLevel.Error);
39+
Program.Log(response.Content.ReadAsStringAsync().Result, "IDPS", BreadcrumbLevel.Debug);
40+
return null;
41+
}
42+
43+
Program.Log(" Downloading IDPS hex", "IDPS");
44+
response = httpClient.GetAsync(idpsHex.Uri).Result;
45+
Program.Log($" {response.StatusCode} {(int)response.StatusCode} (success: {response.IsSuccessStatusCode})", "IDPS");
46+
if (!response.IsSuccessStatusCode)
47+
{
48+
Program.Log("Couldn't fetch the IDPS from the PS3 because of a bad status code.", "IDPS", BreadcrumbLevel.Error);
49+
Program.Log(response.Content.ReadAsStringAsync().Result, "IDPS", BreadcrumbLevel.Debug);
50+
return null;
51+
}
3352

3453
//Return the IDPS key
35-
return httpClient.GetAsync(idpsHex.Uri).Result.Content.ReadAsByteArrayAsync().Result;
54+
return response.Content.ReadAsByteArrayAsync().Result;
3655
});
3756
}
3857

Refresher/UI/IntegratedPatchForm.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,20 @@ private void DownloadLicenseFile(string ebootPath, GameItem game)
274274
}
275275

276276
//If we are using the console patch accessor, fill out the IDPS patch file.
277-
if (this.Accessor is ConsolePatchAccessor consolePatchAccessor)
278-
LibSceToolSharp.SetIdpsKey(consolePatchAccessor.IdpsFile.Value);
277+
if (this.Accessor is ConsolePatchAccessor consolePatchAccessor)
278+
{
279+
byte[]? idps = consolePatchAccessor.IdpsFile.Value;
280+
if (idps == null)
281+
{
282+
Program.Log("Can't set IDPS.", "IDPS", BreadcrumbLevel.Error);
283+
this.FailVerify("Couldn't retrieve the IDPS used for encryption from the PS3. The log may have more details.");
284+
}
285+
else
286+
{
287+
Program.Log("Got the IDPS.", "IDPS", BreadcrumbLevel.Error);
288+
LibSceToolSharp.SetIdpsKey(idps);
289+
}
290+
}
279291

280292
LibSceToolSharp.SetRifPath(licenseDir);
281293
LibSceToolSharp.SetRapDirectory(licenseDir);

0 commit comments

Comments
 (0)