Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix openutau crash when trying to install singer from an encrypted archive file #1144

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions OpenUtau/Strings/Strings.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<system:String x:Key="errors.details">Error Details</system:String>
<system:String x:Key="errors.diffsinger.downloadvocoder1">Error loading vocoder </system:String>
<system:String x:Key="errors.diffsinger.downloadvocoder2">. Please download vocoder from </system:String>
<system:String x:Key="errors.encryptedarchive">Encrypted archive file isn't supported. Please extract the archive file manually.</system:String>
<system:String x:Key="errors.expression.abbrlong">Abbreviation must be between 1 and 4 characters long</system:String>
<system:String x:Key="errors.expression.abbrset">Abbreviation must be set</system:String>
<system:String x:Key="errors.expression.abbrunique">Abbreviations must be unique</system:String>
Expand Down
14 changes: 13 additions & 1 deletion OpenUtau/ViewModels/SingerSetupViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@ public SingerSetupViewModel() {
ArchiveEncoding = Encodings[0];
TextEncoding = Encodings[0];
textItems = new ObservableCollectionExtended<string>();

this.WhenAnyValue(vm => vm.ArchiveFilePath)
.Subscribe(_ => {
if (!string.IsNullOrEmpty(ArchiveFilePath)) {
if(IsEncrypted(ArchiveFilePath)) {
throw new MessageCustomizableException(
"Encrypted archive file isn't supported",
"<translate:errors.encryptedarchive>",
new Exception("Encrypted archive file: " + ArchiveFilePath)
);
}
var config = LoadCharacterYaml(ArchiveFilePath);
MissingInfo = string.IsNullOrEmpty(config?.SingerType);
if (!string.IsNullOrEmpty(config?.TextFileEncoding)) {
Expand Down Expand Up @@ -89,6 +95,12 @@ private void RefreshArchiveItems() {
}
}

private bool IsEncrypted(string archiveFilePath) {
using (var archive = ArchiveFactory.Open(archiveFilePath)) {
return archive.Entries.Any(e => e.IsEncrypted);
}
}

private VoicebankConfig? LoadCharacterYaml(string archiveFilePath) {
using (var archive = ArchiveFactory.Open(archiveFilePath)) {
var entry = archive.Entries.FirstOrDefault(e => Path.GetFileName(e.Key)=="character.yaml");
Expand Down
17 changes: 15 additions & 2 deletions OpenUtau/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,14 @@ async void OnMenuInstallSinger(object sender, RoutedEventArgs args) {
setup.Position = setup.Position.WithY(0);
}
} catch (Exception e) {
_ = MessageBox.ShowError(this, e);
Log.Error(e, $"Failed to install singer {file}");
MessageCustomizableException mce;
if(e is MessageCustomizableException){
mce = (MessageCustomizableException)e;
} else {
mce = new MessageCustomizableException($"Failed to install singer {file}", $"<translate:errors.failed.installsinger>: {file}", e);
}
_ = await MessageBox.ShowError(this, mce);
}
}

Expand Down Expand Up @@ -864,7 +871,13 @@ async void OnDrop(object? sender, DragEventArgs args) {
}
} catch (Exception e) {
Log.Error(e, $"Failed to install singer {file}");
_ = await MessageBox.ShowError(this, new MessageCustomizableException("Failed to install singer", "<translate:errors.failed.installsinger>", e));
MessageCustomizableException mce;
if(e is MessageCustomizableException){
mce = (MessageCustomizableException)e;
} else {
mce = new MessageCustomizableException($"Failed to install singer {file}", $"<translate:errors.failed.installsinger>: {file}", e);
}
_ = await MessageBox.ShowError(this, mce);
}
} else if (ext == Core.Vogen.VogenSingerInstaller.FileExt) {
Core.Vogen.VogenSingerInstaller.Install(file);
Expand Down
Loading