From b95f4372895f1bfbc8df07b75ce154ff126b1bd8 Mon Sep 17 00:00:00 2001 From: Umbrason Date: Mon, 30 Jun 2025 23:13:19 +0200 Subject: [PATCH 1/2] fix move across volumes change from Directory.Move to File.Move --- .../CustomDistributions/RetroRewind.cs | 54 +++++++++---------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/WheelWizard/Features/CustomDistributions/RetroRewind.cs b/WheelWizard/Features/CustomDistributions/RetroRewind.cs index 1eeb73f1..7039eb0b 100644 --- a/WheelWizard/Features/CustomDistributions/RetroRewind.cs +++ b/WheelWizard/Features/CustomDistributions/RetroRewind.cs @@ -74,13 +74,8 @@ private async Task DownloadAndExtractRetroRewind(ProgressWindow //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; + OperationResult? result = null; try { // 1) Download @@ -110,26 +105,22 @@ private async Task DownloadAndExtractRetroRewind(ProgressWindow return new DirectoryNotFoundException($"Could not find a '{FolderName}' folder inside {tempExtractionPath}"); } - // 4) Replace existing install, if any - if (_fileSystem.Directory.Exists(distributionDataDestination)) - _fileSystem.Directory.Delete(distributionDataDestination, recursive: true); - if (_fileSystem.File.Exists(riivolutionDiscXMLFile)) - _fileSystem.File.Delete(riivolutionDiscXMLFile); - - // 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}`"); - - // 5) Move over distribution data - _fileSystem.Directory.Move(sourceFolder, distributionDataDestination); + // 4) Remove existing install, if any + var removeResult = await RemoveAsync(progressWindow); + if (removeResult.IsFailure) + { + result = removeResult; + throw new Exception(removeResult.Error.Message); + } - // 6) Move over 'riivolution/' folder. skip existing files + // 5) Move over RetroRewind var xmlFolderSource = _fileSystem.Path.Combine(tempExtractionPath, XMLFolderName); - foreach (var file in _fileSystem.Directory.EnumerateFiles(xmlFolderSource, "*", SearchOption.AllDirectories)) + var riivolutionFiles = _fileSystem.Directory.EnumerateFiles(xmlFolderSource, "*", SearchOption.AllDirectories); + var folderSource = _fileSystem.Path.Combine(tempExtractionPath, FolderName); + var retroRewindFiles = _fileSystem.Directory.EnumerateFiles(folderSource, "*", SearchOption.AllDirectories); + foreach (var file in riivolutionFiles.Concat(retroRewindFiles)) { - var destinationPath = _fileSystem.Path.Combine(riivolutionFolderDestination, _fileSystem.Path.GetRelativePath(xmlFolderSource, file)); + var destinationPath = _fileSystem.Path.Combine(destinationParentDir.FullName, _fileSystem.Path.GetRelativePath(tempExtractionPath, file)); var destinationDirectoryName = _fileSystem.Path.GetDirectoryName(destinationPath); if (destinationDirectoryName != null) { @@ -137,7 +128,7 @@ private async Task DownloadAndExtractRetroRewind(ProgressWindow if (!directory?.Exists ?? false) directory?.Create(); } - _fileSystem.File.Move(file, destinationPath, false); + _fileSystem.File.Move(file, destinationPath, false); //skip existing files for safety } } catch (Exception e) @@ -152,7 +143,7 @@ private async Task DownloadAndExtractRetroRewind(ProgressWindow if (_fileSystem.Directory.Exists(tempExtractionPath)) _fileSystem.Directory.Delete(tempExtractionPath, recursive: true); } - return exception is null ? Ok() : Fail(exception); + return result ?? (exception is not null ? Fail(exception) : Ok()); } private async Task BackupOldrksys() @@ -542,9 +533,16 @@ List allDeletions public Task RemoveAsync(ProgressWindow progressWindow) { - var retroRewindPath = _fileSystem.Path.Combine(PathManager.RiivolutionWhWzFolderPath, FolderName); - if (_fileSystem.Directory.Exists(retroRewindPath)) - _fileSystem.Directory.Delete(retroRewindPath, true); + //where the RR distribution lives + var distributionDataDestination = _fileSystem.Path.Combine(PathManager.RiivolutionWhWzFolderPath, FolderName); + //where the RR wiiDisc xml file lives + var riivolutionDiscXMLFile = _fileSystem.Path.Combine(PathManager.RiivolutionWhWzFolderPath, XMLFolderName, $"{XMLFileName}.xml"); + + if (_fileSystem.Directory.Exists(distributionDataDestination)) + _fileSystem.Directory.Delete(distributionDataDestination, recursive: true); + if (_fileSystem.File.Exists(riivolutionDiscXMLFile)) + _fileSystem.File.Delete(riivolutionDiscXMLFile); + return Task.FromResult(Ok()); } From 7559eede03f48cba40b1e6bb9ce16138fa3e3ebc Mon Sep 17 00:00:00 2001 From: Umbrason Date: Tue, 1 Jul 2025 03:47:29 +0200 Subject: [PATCH 2/2] Ensure unix read permission is set --- WheelWizard/Features/CustomDistributions/RetroRewind.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/WheelWizard/Features/CustomDistributions/RetroRewind.cs b/WheelWizard/Features/CustomDistributions/RetroRewind.cs index 7039eb0b..f1bed2e8 100644 --- a/WheelWizard/Features/CustomDistributions/RetroRewind.cs +++ b/WheelWizard/Features/CustomDistributions/RetroRewind.cs @@ -362,6 +362,8 @@ private OperationResult ExtractZipFile(string path, string destinationDirectory, if (!string.IsNullOrEmpty(dir)) _fileSystem.Directory.CreateDirectory(dir); + // Ensure read permission is set + entry.ExternalAttributes |= Convert.ToInt32("644", 8) << 16; // Extract the file entry.ExtractToFile(destinationPath, overwrite: true); }