Browse Source

Convert remaining path combines to os independent

pull/55/head
Ionite 1 year ago
parent
commit
d32f1baec3
No known key found for this signature in database
  1. 2
      StabilityMatrix.Avalonia/DesignData/DesignData.cs
  2. 2
      StabilityMatrix.Avalonia/ViewModels/Dialogs/InstallerViewModel.cs
  3. 7
      StabilityMatrix.Avalonia/ViewModels/Dialogs/OneClickInstallViewModel.cs
  4. 3
      StabilityMatrix.Avalonia/ViewModels/LaunchPageViewModel.cs
  5. 5
      StabilityMatrix.Core/Helper/HardwareHelper.cs
  6. 2
      StabilityMatrix.Core/Models/InstalledPackage.cs

2
StabilityMatrix.Avalonia/DesignData/DesignData.cs

@ -49,7 +49,7 @@ public static class DesignData
DisplayName = "My Installed Package", DisplayName = "My Installed Package",
PackageName = "stable-diffusion-webui", PackageName = "stable-diffusion-webui",
PackageVersion = "v1.0.0", PackageVersion = "v1.0.0",
LibraryPath = "Packages\\example-webui", LibraryPath = $"Packages{Environment.NewLine}example-webui",
LastUpdateCheck = DateTimeOffset.Now LastUpdateCheck = DateTimeOffset.Now
} }
}, },

2
StabilityMatrix.Avalonia/ViewModels/Dialogs/InstallerViewModel.cs

@ -189,7 +189,7 @@ public partial class InstallerViewModel : ContentDialogViewModelBase
var package = new InstalledPackage var package = new InstalledPackage
{ {
DisplayName = SelectedPackage.DisplayName, DisplayName = SelectedPackage.DisplayName,
LibraryPath = $"Packages\\{InstallName}", LibraryPath = Path.Combine("Packages", InstallName),
Id = Guid.NewGuid(), Id = Guid.NewGuid(),
PackageName = SelectedPackage.Name, PackageName = SelectedPackage.Name,
PackageVersion = version, PackageVersion = version,

7
StabilityMatrix.Avalonia/ViewModels/Dialogs/OneClickInstallViewModel.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
@ -114,11 +115,13 @@ public partial class OneClickInstallViewModel : ViewModelBase
} }
IsIndeterminate = false; IsIndeterminate = false;
var libraryDir = settingsManager.LibraryDir;
// get latest version & download & install // get latest version & download & install
SubHeaderText = "Getting latest version..."; SubHeaderText = "Getting latest version...";
var latestVersion = await SelectedPackage.GetLatestVersion(); var latestVersion = await SelectedPackage.GetLatestVersion();
SelectedPackage.InstallLocation = SelectedPackage.InstallLocation =
$"{settingsManager.LibraryDir}\\Packages\\{SelectedPackage.Name}"; Path.Combine(libraryDir, "Packages", SelectedPackage.Name);
SelectedPackage.ConsoleOutput += (_, output) => SubSubHeaderText = output.Text; SelectedPackage.ConsoleOutput += (_, output) => SubSubHeaderText = output.Text;
await DownloadPackage(latestVersion); await DownloadPackage(latestVersion);
@ -130,7 +133,7 @@ public partial class OneClickInstallViewModel : ViewModelBase
var installedPackage = new InstalledPackage var installedPackage = new InstalledPackage
{ {
DisplayName = SelectedPackage.DisplayName, DisplayName = SelectedPackage.DisplayName,
LibraryPath = $"Packages\\{SelectedPackage.Name}", LibraryPath = Path.Combine("Packages", SelectedPackage.Name),
Id = Guid.NewGuid(), Id = Guid.NewGuid(),
PackageName = SelectedPackage.Name, PackageName = SelectedPackage.Name,
PackageVersion = latestVersion, PackageVersion = latestVersion,

3
StabilityMatrix.Avalonia/ViewModels/LaunchPageViewModel.cs

@ -2,6 +2,7 @@
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -158,7 +159,7 @@ public partial class LaunchPageViewModel : PageViewModelBase, IDisposable
await pyRunner.Initialize(); await pyRunner.Initialize();
// Get path from package // Get path from package
var packagePath = $"{settingsManager.LibraryDir}\\{activeInstall.LibraryPath!}"; var packagePath = Path.Combine(settingsManager.LibraryDir, activeInstall.LibraryPath!);
basePackage.ConsoleOutput += OnProcessOutputReceived; basePackage.ConsoleOutput += OnProcessOutputReceived;
basePackage.Exited += OnProcessExited; basePackage.Exited += OnProcessExited;

5
StabilityMatrix.Core/Helper/HardwareHelper.cs

@ -73,7 +73,7 @@ public static partial class HardwareHelper
name = match.Groups[1].Value.Trim(); name = match.Groups[1].Value.Trim();
} }
match = MyRegex().Match(gpuOutput); match = Regex.Match(gpuOutput, @"prefetchable\) \[size=(\\d+)M\]");
if (match.Success) if (match.Success)
{ {
memoryBytes = ulong.Parse(match.Groups[1].Value) * 1024 * 1024; memoryBytes = ulong.Parse(match.Groups[1].Value) * 1024 * 1024;
@ -123,9 +123,6 @@ public static partial class HardwareHelper
{ {
return IterGpuInfo().Any(gpu => gpu.IsAmd); return IterGpuInfo().Any(gpu => gpu.IsAmd);
} }
[GeneratedRegex("prefetchable\\) \\[size=(\\d+)M\\]")]
private static partial Regex MyRegex();
} }
public enum Level public enum Level

2
StabilityMatrix.Core/Models/InstalledPackage.cs

@ -52,7 +52,7 @@ public class InstalledPackage
// Further check if the path is a sub-path of the library // Further check if the path is a sub-path of the library
var isSubPath = relativePath != "." var isSubPath = relativePath != "."
&& relativePath != ".." && relativePath != ".."
&& !relativePath.StartsWith("..\\") && !relativePath.StartsWith(".." + Environment.NewLine)
&& !System.IO.Path.IsPathRooted(relativePath); && !System.IO.Path.IsPathRooted(relativePath);
return isSubPath ? relativePath : null; return isSubPath ? relativePath : null;
} }

Loading…
Cancel
Save