Skip to content

Commit

Permalink
Merge pull request #1163 from maiko3tattun/240530_FixSingerInstall
Browse files Browse the repository at this point in the history
Fixed crash when unzipping singer fails
  • Loading branch information
stakira authored Jun 9, 2024
2 parents 54659b5 + 82242f3 commit f68e800
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions OpenUtau/ViewModels/SingerSetupViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,28 @@ private void RefreshTextItems() {
ArchiveEncoding = new ArchiveEncoding { Forced = ArchiveEncoding },
};
using (var archive = ArchiveFactory.Open(ArchiveFilePath, readerOptions)) {
textItems.Clear();
foreach (var entry in archive.Entries.Where(entry => entry.Key.EndsWith("character.txt") || entry.Key.EndsWith("oto.ini"))) {
using (var stream = entry.OpenEntryStream()) {
using var reader = new StreamReader(stream, TextEncoding);
textItems.Add($"------ {entry.Key} ------");
int count = 0;
while (count < 256 && !reader.EndOfStream) {
string? line = reader.ReadLine();
if (!string.IsNullOrWhiteSpace(line)) {
textItems.Add(line);
count++;
try {
textItems.Clear();
foreach (var entry in archive.Entries.Where(entry => entry.Key.EndsWith("character.txt") || entry.Key.EndsWith("oto.ini"))) {
using (var stream = entry.OpenEntryStream()) {
using var reader = new StreamReader(stream, TextEncoding);
textItems.Add($"------ {entry.Key} ------");
int count = 0;
while (count < 256 && !reader.EndOfStream) {
string? line = reader.ReadLine();
if (!string.IsNullOrWhiteSpace(line)) {
textItems.Add(line);
count++;
}
}
if (!reader.EndOfStream) {
textItems.Add($"...");
}
}
if (!reader.EndOfStream) {
textItems.Add($"...");
}
}
} catch (Exception ex) {
DocManager.Inst.ExecuteCmd(new ErrorMessageNotification(ex));
Step--;
}
}
}
Expand Down

0 comments on commit f68e800

Please sign in to comment.