diff --git a/StabilityMatrix.Avalonia/Assets.cs b/StabilityMatrix.Avalonia/Assets.cs index 75ea15d6..caf3cbc5 100644 --- a/StabilityMatrix.Avalonia/Assets.cs +++ b/StabilityMatrix.Avalonia/Assets.cs @@ -92,8 +92,7 @@ internal static class Assets /// public static async Task ExtractAsset(Uri assetUri, string targetDirectory, bool overwrite = true) { - var assetPath = assetUri.AbsolutePath; - var assetName = Path.GetFileName(assetPath); + var assetName = Path.GetFileName(assetUri.ToString()); var targetPath = Path.Combine(targetDirectory, assetName); if (File.Exists(targetPath) && !overwrite) { diff --git a/StabilityMatrix.Avalonia/Helpers/UnixPrerequisiteHelper.cs b/StabilityMatrix.Avalonia/Helpers/UnixPrerequisiteHelper.cs index 820c750b..a3cf3177 100644 --- a/StabilityMatrix.Avalonia/Helpers/UnixPrerequisiteHelper.cs +++ b/StabilityMatrix.Avalonia/Helpers/UnixPrerequisiteHelper.cs @@ -8,6 +8,7 @@ using Avalonia.Platform; using NLog; using StabilityMatrix.Core.Exceptions; using StabilityMatrix.Core.Helper; +using StabilityMatrix.Core.Models.FileInterfaces; using StabilityMatrix.Core.Models.Progress; using StabilityMatrix.Core.Processes; using StabilityMatrix.Core.Services; @@ -22,15 +23,15 @@ public class UnixPrerequisiteHelper : IPrerequisiteHelper private readonly IDownloadService downloadService; private readonly ISettingsManager settingsManager; - private string HomeDir => settingsManager.LibraryDir; - private string AssetsDir => Path.Combine(HomeDir, "Assets"); - - private string PythonDir => Path.Combine(AssetsDir, "Python310"); - private string PythonDllPath => Path.Combine(PythonDir, "python310.dll"); - public bool IsPythonInstalled => File.Exists(PythonDllPath); + private DirectoryPath HomeDir => settingsManager.LibraryDir; + private DirectoryPath AssetsDir => HomeDir + "Assets"; + + private DirectoryPath PythonDir => AssetsDir + "Python310"; + private FilePath PythonDllPath => PythonDir + "python310.dll"; + public bool IsPythonInstalled => PythonDllPath.Exists; - private string PortableGitInstallDir => Path.Combine(HomeDir, "PortableGit"); - public string GitBinPath => Path.Combine(PortableGitInstallDir, "bin"); + private DirectoryPath PortableGitInstallDir => HomeDir + "PortableGit"; + public string GitBinPath => PortableGitInstallDir + "bin"; public UnixPrerequisiteHelper(IDownloadService downloadService, ISettingsManager settingsManager) @@ -106,7 +107,10 @@ public class UnixPrerequisiteHelper : IPrerequisiteHelper // Extract Logger.Info($"Extracting Python Zip: {downloadPath} to {PythonDir}"); - Directory.Delete(PythonDir, true); + if (PythonDir.Exists) + { + await PythonDir.DeleteAsync(true); + } if (progress != null) { await ArchiveHelper.Extract7Z(downloadPath, PythonDir, progress);