Skip to content

Commit

Permalink
Check Legacy Post Update
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisFeline committed Oct 12, 2024
1 parent f2abe3d commit 7857f31
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 10 deletions.
13 changes: 8 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Latest Changelog

- Fixed OSC map values being mixed up sometimes. It should be consistent now.
- Fixed OSC Item Status for CorkScrew coil.
- Please note that Item Status only works with a specific set of items.
- Fixed a button on the Settings window slicing the text on high DPI resolution.
- Updated Japanese localization. (Thank you @nomlasvrc)
- The Save Manager program is a single file now. YAY
- Removed the pop-up message when you click a save code. A better less intrusive method have been implemented.
- Aditionally, a sound will play when you copy a save code. (Can be disabled in Settings)
- The custom sound notifications in settings have been reworked too.
- The 'Auto Copy' feature will also play an audio if the 'Play Audio on Copy' setting is enabled.
- Fixed OSC colors for Double Trouble.
- Reworked the Automatic Updates.
- Updated Traditional Chinese localization (Thank you @XoF-eLtTiL)
3 changes: 1 addition & 2 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ static void Main(string[] args)
Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

LANG.Initialize();

if (ContainsArg("--post-update")) Updater.PostUpdate(args);
Updater.CheckPostUpdate(args);

if (CheckMutex())
{
Expand Down
40 changes: 37 additions & 3 deletions Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public void Done() {
}
}

const string POST_UPDATE_ARG = "--clean-update";
internal static void Start(GitHubRelease release, GitHubRelease.Asset asset) {
AllocConsole();

Expand Down Expand Up @@ -105,7 +106,7 @@ internal static void Start(GitHubRelease release, GitHubRelease.Asset asset) {

Program.ReleaseMutex(); // Release mutex so downloaded app opens properly
// Start new process with --post-update
ProcessStartInfo processInfo = new ProcessStartInfo(Program.ProgramFile, "--post-update");
ProcessStartInfo processInfo = new ProcessStartInfo(Program.ProgramFile, POST_UPDATE_ARG);
Process.Start(processInfo);
// Exit this app
Application.Exit();
Expand All @@ -123,7 +124,10 @@ internal static void Start(GitHubRelease release, GitHubRelease.Asset asset) {
}
}

internal static void PostUpdate(string[] args) {
const string LEGACY_POST_UPDATE_ARG = "--post-update";
internal static void CheckPostUpdate(string[] args) {
bool updateLegacy = Program.ContainsArg(LEGACY_POST_UPDATE_ARG);
if (!updateLegacy && !Program.ContainsArg(POST_UPDATE_ARG)) return;
Logger.Info("Running post-update cleanup.");

try {
Expand All @@ -140,6 +144,36 @@ internal static void PostUpdate(string[] args) {
}
}

if (updateLegacy) {
// Run legacy cleanup, old to new transition
Logger.Info("Updated from legacy version, running legacy cleanup...");

try {
string legacyTempFiles = Path.Combine(Program.ProgramDirectory, ".temp_files");
if (Directory.Exists(legacyTempFiles)) {
Logger.Info("Deleting legacy temp files: " + legacyTempFiles);
Directory.Delete(legacyTempFiles, true);
}
} catch (Exception ex) {
Logger.Error(ex);
}

try {
Logger.Info("Deleting unused legacy files.");
var unusedFiles = Directory.GetFiles(Program.ProgramDirectory)
.Where(f => f.EndsWith(".pdb") || f.EndsWith(".dll"));

foreach (string file in unusedFiles) {
try {
Logger.Info("Deleting unused file: " + file);
File.Delete(file);
} catch { }
}
} catch (Exception ex) {
Logger.Error(ex);
}
}

if (File.Exists(Program.ProgramLocationTemporary)) {
Logger.Info("Deleting old program files.");
File.Delete(Program.ProgramLocationTemporary);
Expand All @@ -151,7 +185,7 @@ internal static void PostUpdate(string[] args) {
Logger.Error("Failed to run post-update.");
Logger.Error(ex);

MessageBox.Show("Failed to run post-update.\n\n" + ex, "Update Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Failed to run post-update.\nPlease report this issue on the GitHub page.\n\n" + ex, "Update Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

Expand Down

0 comments on commit 7857f31

Please sign in to comment.