Skip to content

Commit 600730a

Browse files
committed
Improve checking/error handling
1 parent 8d6b779 commit 600730a

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

Refresher/Accessors/ConsolePatchAccessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public override Stream OpenRead(string path)
4747
// return this._client.OpenRead(GetPath(path));
4848
}
4949

50-
public override Stream OpenWrite(string path) => this._client.OpenWrite(GetPath(path));
50+
public override Stream OpenWrite(string path) => this._client.OpenWrite(GetPath(path), FtpDataType.Binary, false);
5151

5252
public override void RemoveFile(string path) => this._client.DeleteFile(GetPath(path));
5353

Refresher/UI/IntegratedPatchForm.cs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,17 @@ protected virtual void PathChanged(object? sender, EventArgs ev)
6363
GameItem item = new();
6464

6565
string iconPath = Path.Combine(gamePath, "ICON0.PNG");
66-
if (this.Accessor.FileExists(iconPath))
66+
try
67+
{
68+
if (this.Accessor.FileExists(iconPath))
69+
{
70+
using Stream iconStream = this.Accessor.OpenRead(iconPath);
71+
item.Image = new Bitmap(iconStream).WithSize(new Size(64, 64));
72+
}
73+
}
74+
catch
6775
{
68-
using Stream iconStream = this.Accessor.OpenRead(iconPath);
69-
item.Image = new Bitmap(iconStream).WithSize(new Size(64, 64));
76+
// don't set any image
7077
}
7178

7279
string sfoPath = Path.Combine(gamePath, "PARAM.SFO");
@@ -163,13 +170,13 @@ public override void CompletePatch(object? sender, EventArgs e) {
163170
string backup = destination + ".ORIG";
164171
if (!this.Accessor.FileExists(backup))
165172
this.Accessor.CopyFile(destination, backup);
166-
167-
this.Accessor.RemoveFile(destination);
168173
}
169-
170-
// wait a second for the ps3 to calm the fuck down
171-
// this is apparently necessary
172-
Thread.Sleep(1000); // TODO: don't. block. the. main. fucking. thread.
174+
175+
if (this.Accessor.FileExists(destination))
176+
this.Accessor.RemoveFile(destination);
177+
178+
// wait a second for the ps3 to calm down
179+
Thread.Sleep(1000); // TODO: don't. block. the. main. thread.
173180

174181
this.Accessor.UploadFile(fileToUpload, destination);
175182
MessageBox.Show($"Successfully patched EBOOT! It was saved to '{destination}'.");
@@ -191,13 +198,19 @@ private void RevertToOriginalExecutable(object? sender, EventArgs e)
191198
{
192199
if (this.Accessor == null) return;
193200

194-
if (!this.Accessor.FileExists(this._usrDir + "EBOOT.BIN.ORIG"))
201+
string eboot = this._usrDir + "EBOOT.BIN";
202+
string ebootOrig = this._usrDir + "EBOOT.BIN.ORIG";
203+
204+
if (!this.Accessor.FileExists(ebootOrig))
195205
{
196206
MessageBox.Show("Cannot revert EBOOT since the original EBOOT does not exist", MessageBoxType.Error);
197207
return;
198208
}
199209

200-
this.Accessor.CopyFile(this._usrDir + "EBOOT.BIN.ORIG", this._usrDir + "EBOOT.BIN");
210+
if(this.Accessor.FileExists(eboot))
211+
this.Accessor.RemoveFile(eboot);
212+
213+
this.Accessor.CopyFile(ebootOrig, eboot);
201214
MessageBox.Show("The EBOOT has successfully been reverted to it's original backup");
202215
}
203216

0 commit comments

Comments
 (0)