From f6f329684bb792dd123b9957c8c397f43fc2abc4 Mon Sep 17 00:00:00 2001 From: Umbrason Date: Sun, 29 Jun 2025 20:01:32 +0200 Subject: [PATCH 1/3] Fix initial RetroRewind installation crashing WheelWizard Creating the parent directory for the 'finalDestination' recursively to avoid a potential crash from Directory.Move --- WheelWizard/Features/CustomDistributions/RetroRewind.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/WheelWizard/Features/CustomDistributions/RetroRewind.cs b/WheelWizard/Features/CustomDistributions/RetroRewind.cs index 9c71fc25..ca74a357 100644 --- a/WheelWizard/Features/CustomDistributions/RetroRewind.cs +++ b/WheelWizard/Features/CustomDistributions/RetroRewind.cs @@ -105,6 +105,12 @@ private async Task DownloadAndExtractRetroRewind(ProgressWindow _fileSystem.Directory.Delete(finalDestination, recursive: true); // 5) Move into place + // Make sure the parent directory of 'finalDestination' exists + var parentDirectory = _fileSystem.DirectoryInfo.New(finalDestination).Parent; + parentDirectory?.Create(); + if ((!parentDirectory?.Exists) ?? true) + throw new DirectoryNotFoundException($"Could not find destination `{parentDirectory?.FullName}`"); + _fileSystem.Directory.Move(sourceFolder, finalDestination); } finally From f2bbcd4ce9ed4b35f58f61b31a87010172fccf00 Mon Sep 17 00:00:00 2001 From: Umbrason Date: Sun, 29 Jun 2025 21:47:16 +0200 Subject: [PATCH 2/3] Add proper error handling --- .../Features/CustomDistributions/RetroRewind.cs | 8 ++++++-- WheelWizard/Services/Launcher/RrLauncher.cs | 10 +++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/WheelWizard/Features/CustomDistributions/RetroRewind.cs b/WheelWizard/Features/CustomDistributions/RetroRewind.cs index ca74a357..eff153d7 100644 --- a/WheelWizard/Features/CustomDistributions/RetroRewind.cs +++ b/WheelWizard/Features/CustomDistributions/RetroRewind.cs @@ -70,7 +70,7 @@ private async Task DownloadAndExtractRetroRewind(ProgressWindow var tempExtractionPath = PathManager.TempModsFolderPath; // where the final RR folder should live var finalDestination = _fileSystem.Path.Combine(PathManager.RiivolutionWhWzFolderPath, FolderName); - + Exception? exception = null; try { // 1) Download @@ -113,6 +113,10 @@ private async Task DownloadAndExtractRetroRewind(ProgressWindow _fileSystem.Directory.Move(sourceFolder, finalDestination); } + catch (Exception e) + { + exception = e; + } finally { if (_fileSystem.File.Exists(tempZipPath)) @@ -121,7 +125,7 @@ private async Task DownloadAndExtractRetroRewind(ProgressWindow if (_fileSystem.Directory.Exists(tempExtractionPath)) _fileSystem.Directory.Delete(tempExtractionPath, recursive: true); } - return Ok(); + return exception is null ? Ok() : Fail(exception); } private async Task BackupOldrksys() diff --git a/WheelWizard/Services/Launcher/RrLauncher.cs b/WheelWizard/Services/Launcher/RrLauncher.cs index 3809ed02..4475325a 100644 --- a/WheelWizard/Services/Launcher/RrLauncher.cs +++ b/WheelWizard/Services/Launcher/RrLauncher.cs @@ -66,8 +66,16 @@ public async Task Install() { var progressWindow = new ProgressWindow(); progressWindow.Show(); - await CustomDistributionSingletonService.RetroRewind.InstallAsync(progressWindow); + var installResult = await CustomDistributionSingletonService.RetroRewind.InstallAsync(progressWindow); progressWindow.Close(); + if (installResult.IsFailure) + { + await new MessageBoxWindow() + .SetMessageType(MessageBoxWindow.MessageType.Error) + .SetTitleText("Unable to install RetroRewind") + .SetInfoText(installResult.Error.Message) + .ShowDialog(); + } } public async Task Update() From 5a885fc87c9d650db5d4b843a0ba3a5748c57ef2 Mon Sep 17 00:00:00 2001 From: Umbrason Date: Mon, 30 Jun 2025 00:44:10 +0200 Subject: [PATCH 3/3] fix missing RetroRewind6.xml on initial install fixed by also moving over the riivolution/ folder contents. skips existing files. RetroRewind6.xml is deleted before copying to replace when updating. --- .../CustomDistributions/IDistribution.cs | 10 +++++ .../CustomDistributions/RetroRewind.cs | 43 +++++++++++++++---- WheelWizard/Services/PathManager.cs | 3 +- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/WheelWizard/Features/CustomDistributions/IDistribution.cs b/WheelWizard/Features/CustomDistributions/IDistribution.cs index 51f6e2fd..d2398c78 100644 --- a/WheelWizard/Features/CustomDistributions/IDistribution.cs +++ b/WheelWizard/Features/CustomDistributions/IDistribution.cs @@ -18,6 +18,16 @@ public interface IDistribution /// string FolderName { get; } + /// + /// The name of the wiiDisc .xml file in XMLFolderName + /// + string XMLFileName { get; } + + /// + /// The name of the folder containing the distributions wiiDisc .xml file + /// + string XMLFolderName { get; } + /// /// Install the distribution. /// diff --git a/WheelWizard/Features/CustomDistributions/RetroRewind.cs b/WheelWizard/Features/CustomDistributions/RetroRewind.cs index eff153d7..1eeb73f1 100644 --- a/WheelWizard/Features/CustomDistributions/RetroRewind.cs +++ b/WheelWizard/Features/CustomDistributions/RetroRewind.cs @@ -29,6 +29,8 @@ public RetroRewind(IFileSystem fileSystem, IApiCaller api) // Keep in mind, whenever we download update files from the server, they are actually 1 folder higher, so it contains this folder. public string FolderName => "RetroRewind6"; + public string XMLFolderName => "riivolution"; + public string XMLFileName => "RetroRewind6"; public async Task InstallAsync(ProgressWindow progressWindow) { @@ -68,8 +70,16 @@ private async Task DownloadAndExtractRetroRewind(ProgressWindow var tempZipPath = PathManager.RetroRewindTempFile; // where we'll do the extraction var tempExtractionPath = PathManager.TempModsFolderPath; - // where the final RR folder should live - var finalDestination = _fileSystem.Path.Combine(PathManager.RiivolutionWhWzFolderPath, FolderName); + + //where all distributions are stored + var destinationParentDir = _fileSystem.DirectoryInfo.New(PathManager.RiivolutionWhWzFolderPath); + + //where the RR distribution lives + var distributionDataDestination = _fileSystem.Path.Combine(destinationParentDir.FullName, FolderName); + //where the RR wiiDisc xml file lives + var riivolutionFolderDestination = PathManager.RiivolutionXmlFolderPath; + var riivolutionDiscXMLFile = _fileSystem.Path.Combine(riivolutionFolderDestination, $"{XMLFileName}.xml"); + Exception? exception = null; try { @@ -101,17 +111,34 @@ private async Task DownloadAndExtractRetroRewind(ProgressWindow } // 4) Replace existing install, if any - if (_fileSystem.Directory.Exists(finalDestination)) - _fileSystem.Directory.Delete(finalDestination, recursive: true); + if (_fileSystem.Directory.Exists(distributionDataDestination)) + _fileSystem.Directory.Delete(distributionDataDestination, recursive: true); + if (_fileSystem.File.Exists(riivolutionDiscXMLFile)) + _fileSystem.File.Delete(riivolutionDiscXMLFile); - // 5) Move into place - // Make sure the parent directory of 'finalDestination' exists - var parentDirectory = _fileSystem.DirectoryInfo.New(finalDestination).Parent; + // 5) Make sure the target directory exists + var parentDirectory = _fileSystem.DirectoryInfo.New(distributionDataDestination).Parent; parentDirectory?.Create(); if ((!parentDirectory?.Exists) ?? true) throw new DirectoryNotFoundException($"Could not find destination `{parentDirectory?.FullName}`"); - _fileSystem.Directory.Move(sourceFolder, finalDestination); + // 5) Move over distribution data + _fileSystem.Directory.Move(sourceFolder, distributionDataDestination); + + // 6) Move over 'riivolution/' folder. skip existing files + var xmlFolderSource = _fileSystem.Path.Combine(tempExtractionPath, XMLFolderName); + foreach (var file in _fileSystem.Directory.EnumerateFiles(xmlFolderSource, "*", SearchOption.AllDirectories)) + { + var destinationPath = _fileSystem.Path.Combine(riivolutionFolderDestination, _fileSystem.Path.GetRelativePath(xmlFolderSource, file)); + var destinationDirectoryName = _fileSystem.Path.GetDirectoryName(destinationPath); + if (destinationDirectoryName != null) + { + var directory = _fileSystem.DirectoryInfo.New(destinationDirectoryName); + if (!directory?.Exists ?? false) + directory?.Create(); + } + _fileSystem.File.Move(file, destinationPath, false); + } } catch (Exception e) { diff --git a/WheelWizard/Services/PathManager.cs b/WheelWizard/Services/PathManager.cs index 251952c9..26f3fe9b 100644 --- a/WheelWizard/Services/PathManager.cs +++ b/WheelWizard/Services/PathManager.cs @@ -53,7 +53,8 @@ public static class PathManager // This is not the folder your save file is located in, but its the folder where every Region folder is, so the save file is in SaveFolderPath/Region public static string SaveFolderPath => Path.Combine(RiivolutionWhWzFolderPath, "riivolution", "save", "RetroWFC"); - public static string XmlFilePath => Path.Combine(RiivolutionWhWzFolderPath, "riivolution", "RetroRewind6.xml"); + public static string RiivolutionXmlFolderPath => Path.Combine(RiivolutionWhWzFolderPath, "riivolution"); + public static string XmlFilePath => Path.Combine(RiivolutionXmlFolderPath, "RetroRewind6.xml"); private static string PortableUserFolderPath => Path.Combine(GetDolphinExeDirectory(), RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "user" : "User");