Skip to content

Commit 43430e7

Browse files
authored
Merge pull request #306 from LykosAI/main
2 parents e85f03a + fe8a711 commit 43430e7

File tree

4 files changed

+64
-49
lines changed

4 files changed

+64
-49
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to Stability Matrix will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2.0.0.html).
77

8+
## v2.6.7
9+
### Fixed
10+
- Fixed prerequisite install not unpacking due to improperly formatted 7z argument (Caused the "python310._pth FileNotFoundException")
11+
- Fixed [#301](https://github.com/LykosAI/StabilityMatrix/issues/301) - Package updates failing silently because of a PortableGit error
12+
813
## v2.6.6
914
### Fixed
1015
- Fixed [#297](https://github.com/LykosAI/StabilityMatrix/issues/297) - Model browser LiteAsyncException occuring when fetching entries with unrecognized values from enum name changes

StabilityMatrix.Avalonia/ViewModels/Dialogs/UpdateViewModel.cs

+21-12
Original file line numberDiff line numberDiff line change
@@ -171,25 +171,34 @@ public async Task Preload()
171171
internal async Task<string> GetReleaseNotes(string changelogUrl)
172172
{
173173
using var client = httpClientFactory.CreateClient();
174-
var response = await client.GetAsync(changelogUrl);
175-
if (response.IsSuccessStatusCode)
176-
{
177-
var changelog = await response.Content.ReadAsStringAsync();
178174

179-
// Formatting for new changelog format
180-
// https://keepachangelog.com/en/1.1.0/
181-
if (changelogUrl.EndsWith(".md", StringComparison.OrdinalIgnoreCase))
175+
try
176+
{
177+
var response = await client.GetAsync(changelogUrl);
178+
if (response.IsSuccessStatusCode)
182179
{
183-
return FormatChangelog(changelog, Compat.AppVersion)
184-
?? "## Unable to format release notes";
180+
var changelog = await response.Content.ReadAsStringAsync();
181+
182+
// Formatting for new changelog format
183+
// https://keepachangelog.com/en/1.1.0/
184+
if (changelogUrl.EndsWith(".md", StringComparison.OrdinalIgnoreCase))
185+
{
186+
return FormatChangelog(changelog, Compat.AppVersion)
187+
?? "## Unable to format release notes";
188+
}
189+
190+
return changelog;
185191
}
186192

187-
return changelog;
193+
return "## Unable to load release notes";
188194
}
189-
else
195+
catch (HttpRequestException e)
190196
{
191-
return "## Unable to load release notes";
197+
return $"## Unable to fetch release notes ({e.StatusCode})\n\n[{changelogUrl}]({changelogUrl})";
192198
}
199+
catch (TaskCanceledException) { }
200+
201+
return $"## Unable to fetch release notes\n\n[{changelogUrl}]({changelogUrl})";
193202
}
194203

195204
partial void OnUpdateInfoChanged(UpdateInfo? value)

StabilityMatrix.Core/Helper/ArchiveHelper.cs

+37-36
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Diagnostics;
2-
using System.Diagnostics.CodeAnalysis;
1+
using System.Diagnostics.CodeAnalysis;
32
using System.Text;
43
using System.Text.RegularExpressions;
54
using NLog;
@@ -59,8 +58,8 @@ public static string SevenZipFileName
5958
public static async Task<ArchiveInfo> TestArchive(string archivePath)
6059
{
6160
var process = ProcessRunner.StartAnsiProcess(SevenZipPath, new[] { "t", archivePath });
62-
await process.WaitForExitAsync();
63-
var output = await process.StandardOutput.ReadToEndAsync();
61+
await process.WaitForExitAsync().ConfigureAwait(false);
62+
var output = await process.StandardOutput.ReadToEndAsync().ConfigureAwait(false);
6463
var matches = Regex7ZOutput().Matches(output);
6564
var size = ulong.Parse(matches[0].Value);
6665
var compressed = ulong.Parse(matches[1].Value);
@@ -86,11 +85,11 @@ public static async Task AddToArchive7Z(string archivePath, string sourceDirecto
8685

8786
public static async Task<ArchiveInfo> Extract7Z(string archivePath, string extractDirectory)
8887
{
88+
var args =
89+
$"x {ProcessRunner.Quote(archivePath)} -o{ProcessRunner.Quote(extractDirectory)} -y";
90+
8991
var result = await ProcessRunner
90-
.GetProcessResultAsync(
91-
SevenZipPath,
92-
new[] { "x", archivePath, "-o" + ProcessRunner.Quote(extractDirectory), "-y" }
93-
)
92+
.GetProcessResultAsync(SevenZipPath, args)
9493
.ConfigureAwait(false);
9594

9695
result.EnsureSuccessExitCode();
@@ -185,7 +184,7 @@ public static async Task<ArchiveInfo> Extract7ZTar(string archivePath, string ex
185184
throw new ArgumentException("Archive must be a zipped tar.");
186185
}
187186
// Extract the tar.gz to tar
188-
await Extract7Z(archivePath, extractDirectory);
187+
await Extract7Z(archivePath, extractDirectory).ConfigureAwait(false);
189188

190189
// Extract the tar
191190
var tarPath = Path.Combine(extractDirectory, Path.GetFileNameWithoutExtension(archivePath));
@@ -196,7 +195,7 @@ public static async Task<ArchiveInfo> Extract7ZTar(string archivePath, string ex
196195

197196
try
198197
{
199-
return await Extract7Z(tarPath, extractDirectory);
198+
return await Extract7Z(tarPath, extractDirectory).ConfigureAwait(false);
200199
}
201200
finally
202201
{
@@ -215,11 +214,11 @@ public static async Task<ArchiveInfo> Extract7ZAuto(string archivePath, string e
215214
{
216215
if (archivePath.EndsWith(".tar.gz"))
217216
{
218-
return await Extract7ZTar(archivePath, extractDirectory);
217+
return await Extract7ZTar(archivePath, extractDirectory).ConfigureAwait(false);
219218
}
220219
else
221220
{
222-
return await Extract7Z(archivePath, extractDirectory);
221+
return await Extract7Z(archivePath, extractDirectory).ConfigureAwait(false);
223222
}
224223
}
225224

@@ -241,7 +240,7 @@ public static async Task Extract(
241240
var count = 0ul;
242241

243242
// Get true size
244-
var (total, _) = await TestArchive(archivePath);
243+
var (total, _) = await TestArchive(archivePath).ConfigureAwait(false);
245244

246245
// If not available, use the size of the archive file
247246
if (total == 0)
@@ -266,32 +265,34 @@ public static async Task Extract(
266265
};
267266
}
268267

269-
await Task.Factory.StartNew(
270-
() =>
271-
{
272-
var extractOptions = new ExtractionOptions
268+
await Task.Factory
269+
.StartNew(
270+
() =>
273271
{
274-
Overwrite = true,
275-
ExtractFullPath = true,
276-
};
277-
using var stream = File.OpenRead(archivePath);
278-
using var archive = ReaderFactory.Open(stream);
272+
var extractOptions = new ExtractionOptions
273+
{
274+
Overwrite = true,
275+
ExtractFullPath = true,
276+
};
277+
using var stream = File.OpenRead(archivePath);
278+
using var archive = ReaderFactory.Open(stream);
279279

280-
// Start the progress reporting timer
281-
progressMonitor?.Start();
280+
// Start the progress reporting timer
281+
progressMonitor?.Start();
282282

283-
while (archive.MoveToNextEntry())
284-
{
285-
var entry = archive.Entry;
286-
if (!entry.IsDirectory)
283+
while (archive.MoveToNextEntry())
287284
{
288-
count += (ulong)entry.CompressedSize;
285+
var entry = archive.Entry;
286+
if (!entry.IsDirectory)
287+
{
288+
count += (ulong)entry.CompressedSize;
289+
}
290+
archive.WriteEntryToDirectory(outputDirectory, extractOptions);
289291
}
290-
archive.WriteEntryToDirectory(outputDirectory, extractOptions);
291-
}
292-
},
293-
TaskCreationOptions.LongRunning
294-
);
292+
},
293+
TaskCreationOptions.LongRunning
294+
)
295+
.ConfigureAwait(false);
295296

296297
progress?.Report(new ProgressReport(progress: 1, message: "Done extracting"));
297298
progressMonitor?.Stop();
@@ -305,7 +306,7 @@ await Task.Factory.StartNew(
305306
public static async Task ExtractManaged(string archivePath, string outputDirectory)
306307
{
307308
await using var stream = File.OpenRead(archivePath);
308-
await ExtractManaged(stream, outputDirectory);
309+
await ExtractManaged(stream, outputDirectory).ConfigureAwait(false);
309310
}
310311

311312
/// <summary>
@@ -381,7 +382,7 @@ public static async Task ExtractManaged(Stream stream, string outputDirectory)
381382
// Write file
382383
await using var entryStream = reader.OpenEntryStream();
383384
await using var fileStream = File.Create(outputPath);
384-
await entryStream.CopyToAsync(fileStream);
385+
await entryStream.CopyToAsync(fileStream).ConfigureAwait(false);
385386
}
386387
}
387388
}

StabilityMatrix.Core/Models/Packages/BaseGitPackage.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public override async Task<InstalledPackageVersion> Update(
309309
new ProgressReport(-1f, "Initializing git repo", isIndeterminate: true)
310310
);
311311
await PrerequisiteHelper
312-
.RunGit(installedPackage.FullPath!, onConsoleOutput, "init")
312+
.RunGit("init", onConsoleOutput, installedPackage.FullPath)
313313
.ConfigureAwait(false);
314314
await PrerequisiteHelper
315315
.RunGit(

0 commit comments

Comments
 (0)