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 application crash when enqueuing to an invalid destination folder #1201

Merged
merged 5 commits into from
Aug 29, 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 TwitchDownloaderCore/TwitchHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,7 @@ public static void CleanUpClaimedFile([AllowNull] FileInfo fileInfo, [AllowNull]
}
}

/// <inheritdoc cref="Directory.CreateDirectory"/>
public static DirectoryInfo CreateDirectory(string path)
{
DirectoryInfo directoryInfo = Directory.CreateDirectory(path);
Expand Down
18 changes: 18 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,12 @@
<data name="ApplicationLanguageTooltip" xml:space="preserve">
<value>¿TwitchDownloaderWPF no está disponible en tu idioma? ¡Haz clic para saber cómo ayudar a traducir!</value>
</data>
<data name="InvalidFolderPath" xml:space="preserve">
<value>Ruta de carpeta no válida</value>
</data>
<data name="InvalidFolderPathMessage" xml:space="preserve">
<value>La carpeta no existe</value>
</data>
<data name="StatusCanceled" xml:space="preserve">
<value>Cancelado</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,12 @@
<data name="ApplicationLanguageTooltip" xml:space="preserve">
<value>TwitchDownloaderWPF n'est pas disponible dans votre langue maternelle ? Cliquez pour apprendre comment aider à traduire !</value>
</data>
<data name="InvalidFolderPath" xml:space="preserve">
<value>Chemin d'accès au répertoire non valide</value>
</data>
<data name="InvalidFolderPathMessage" xml:space="preserve">
<value>Le répertoire n'existe pas</value>
</data>
<data name="StatusCanceled" xml:space="preserve">
<value>Annulé</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.it.resx
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,12 @@
<data name="ApplicationLanguageTooltip" xml:space="preserve">
<value>TwitchDownloaderWPF non è disponibile nella tua lingua? Fai click per sapere come aiutare o tradutte!</value>
</data>
<data name="InvalidFolderPath" xml:space="preserve">
<value>Percorso della cartella non valido</value>
</data>
<data name="InvalidFolderPathMessage" xml:space="preserve">
<value>La cartella non esiste</value>
</data>
<data name="StatusCanceled" xml:space="preserve">
<value>Cancellato</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.ja.resx
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,12 @@
<data name="ApplicationLanguageTooltip" xml:space="preserve">
<value>あなたの母国語でTwitchDownloaderWPFが利用できませんか?クリックで翻訳を手伝う方法を学ぶ!</value>
</data>
<data name="InvalidFolderPath" xml:space="preserve">
<value>不正なフォルダパス</value>
</data>
<data name="InvalidFolderPathMessage" xml:space="preserve">
<value>フォルダが存在しません</value>
</data>
<data name="StatusCanceled" xml:space="preserve">
<value>キャンセルされた</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.pl.resx
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,12 @@
<data name="ApplicationLanguageTooltip" xml:space="preserve">
<value>TwitchDownloaderWPF nie jest dostępny w twoim natywnym języku? Kliknij, aby dowiedzieć się jak nas wspomóc!</value>
</data>
<data name="InvalidFolderPath" xml:space="preserve">
<value>Nieprawidłowa Ścieżka Folderu</value>
</data>
<data name="InvalidFolderPathMessage" xml:space="preserve">
<value>Folder nie istnieje</value>
</data>
<data name="StatusCanceled" xml:space="preserve">
<value>Anulowano</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.pt-br.resx
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,12 @@
<data name="ApplicationLanguageTooltip" xml:space="preserve">
<value>O TwitchDownloaderWPF não está disponível em sua languagem nativa? Clique para aprender como ajudar a traduzir!</value>
</data>
<data name="InvalidFolderPath" xml:space="preserve">
<value>Diretório da Pasta Inválido</value>
</data>
<data name="InvalidFolderPathMessage" xml:space="preserve">
<value>A pasta não existe</value>
</data>
<data name="StatusCanceled" xml:space="preserve">
<value>Cancelado</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,12 @@
<data name="ApplicationLanguageTooltip" xml:space="preserve">
<value>Is TwitchDownloaderWPF not available in your native language? Click to learn how to help translate!</value>
</data>
<data name="InvalidFolderPath" xml:space="preserve">
<value>Invalid Folder Path</value>
</data>
<data name="InvalidFolderPathMessage" xml:space="preserve">
<value>The folder does not exist</value>
</data>
<data name="StatusCanceled" xml:space="preserve">
<value>Canceled</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.ru.resx
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,12 @@
<data name="ApplicationLanguageTooltip" xml:space="preserve">
<value>TwitchDownloaderWPF не доступен на твоем языке? Нажми здесь чтобы узнать как помочь с переводом!</value>
</data>
<data name="InvalidFolderPath" xml:space="preserve">
<value>Неправильный путь к папке</value>
</data>
<data name="InvalidFolderPathMessage" xml:space="preserve">
<value>Папка не существует</value>
</data>
<data name="StatusCanceled" xml:space="preserve">
<value>Отменено</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.tr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,12 @@
<data name="ApplicationLanguageTooltip" xml:space="preserve">
<value>TwitchDownloaderWPF ana dilinizde mevcut değil mi? Çeviriye nasıl yardım edeceğinizi öğrenmek için tıklayın!</value>
</data>
<data name="InvalidFolderPath" xml:space="preserve">
<value>Geçersiz Klasör Yolu</value>
</data>
<data name="InvalidFolderPathMessage" xml:space="preserve">
<value>Klasör mevcut değil</value>
</data>
<data name="StatusCanceled" xml:space="preserve">
<value>İptal edildi</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.uk.resx
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,12 @@
<data name="ApplicationLanguageTooltip" xml:space="preserve">
<value>TwitchDownloaderWPF недоступно на вашій мові? Натисніть тут, щоб дізнатися, як допомогти з перекладом!</value>
</data>
<data name="InvalidFolderPath" xml:space="preserve">
<value>Неправильний шлях до папки</value>
</data>
<data name="InvalidFolderPathMessage" xml:space="preserve">
<value>Папка не існує</value>
</data>
<data name="StatusCanceled" xml:space="preserve">
<value>Скасовано</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions TwitchDownloaderWPF/Translations/Strings.zh-cn.resx
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,12 @@
<data name="ApplicationLanguageTooltip" xml:space="preserve">
<value>TwitchDownloaderWPF 没有你的母语版本?点击了解如何帮助翻译!</value>
</data>
<data name="InvalidFolderPath" xml:space="preserve">
<value>文件夹路径无效</value>
</data>
<data name="InvalidFolderPathMessage" xml:space="preserve">
<value>文件夹不存在</value>
</data>
<data name="StatusCanceled" xml:space="preserve">
<value>已取消</value>
</data>
Expand Down
2 changes: 1 addition & 1 deletion TwitchDownloaderWPF/WindowQueueOptions.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<StackPanel Orientation="Vertical" Grid.Column="1" Grid.Row="1">
<WrapPanel Orientation="Horizontal">
<TextBlock Text="{lex:Loc DownloadFolder}" HorizontalAlignment="Left" Margin="0,6,0,0" VerticalAlignment="Top" Foreground="{DynamicResource AppText}"/>
<TextBox x:Name="textFolder" HorizontalAlignment="Left" Height="23" Margin="3,0,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" MinWidth="300" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}"/>
<TextBox x:Name="textFolder" HorizontalAlignment="Left" Height="23" Margin="3,0,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" MinWidth="300" TextChanged="TextFolder_OnTextChanged" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}"/>
<Button x:Name="btnFolder" Content="{lex:Loc Browse}" HorizontalAlignment="Left" Margin="3,0,0,0" VerticalAlignment="Top" MinWidth="60" Click="btnFolder_Click" Background="{DynamicResource ActionButtonBackground}" Foreground="{DynamicResource ActionButtonText}" BorderBrush="{DynamicResource ActionButtonBorder}"/>
</WrapPanel>
<CheckBox x:Name="checkVideo" Content="{lex:Loc DownloadVideo}" HorizontalAlignment="Left" Margin="0,8,0,0" VerticalAlignment="Top" Checked="CheckVideo_OnChecked" Unchecked="CheckVideo_OnChecked" Foreground="{DynamicResource AppText}" BorderBrush="{DynamicResource AppElementBorder}"/>
Expand Down
107 changes: 99 additions & 8 deletions TwitchDownloaderWPF/WindowQueueOptions.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,21 @@ private void btnQueue_Click(object sender, RoutedEventArgs e)
string folderPath = textFolder.Text;
if (!Directory.Exists(folderPath))
{
TwitchHelper.CreateDirectory(folderPath);
try
{
TwitchHelper.CreateDirectory(folderPath);
}
catch (Exception ex)
{
MessageBox.Show(this, Translations.Strings.InvalidFolderPathMessage, Translations.Strings.InvalidFolderPath, MessageBoxButton.OK, MessageBoxImage.Error);

if (Settings.Default.VerboseErrors)
{
MessageBox.Show(this, ex.ToString(), Translations.Strings.VerboseErrorOutput, MessageBoxButton.OK, MessageBoxImage.Error);
}

return;
}
}

VideoDownloadOptions downloadOptions = vodDownloadPage.GetOptions(null, textFolder.Text);
Expand Down Expand Up @@ -226,7 +240,21 @@ private void btnQueue_Click(object sender, RoutedEventArgs e)
string folderPath = textFolder.Text;
if (!Directory.Exists(folderPath))
{
TwitchHelper.CreateDirectory(folderPath);
try
{
TwitchHelper.CreateDirectory(folderPath);
}
catch (Exception ex)
{
MessageBox.Show(this, Translations.Strings.InvalidFolderPathMessage, Translations.Strings.InvalidFolderPath, MessageBoxButton.OK, MessageBoxImage.Error);

if (Settings.Default.VerboseErrors)
{
MessageBox.Show(this, ex.ToString(), Translations.Strings.VerboseErrorOutput, MessageBoxButton.OK, MessageBoxImage.Error);
}

return;
}
}

ClipDownloadOptions downloadOptions = new ClipDownloadOptions
Expand Down Expand Up @@ -330,7 +358,21 @@ private void btnQueue_Click(object sender, RoutedEventArgs e)
string folderPath = textFolder.Text;
if (!Directory.Exists(folderPath))
{
TwitchHelper.CreateDirectory(folderPath);
try
{
TwitchHelper.CreateDirectory(folderPath);
}
catch (Exception ex)
{
MessageBox.Show(this, Translations.Strings.InvalidFolderPathMessage, Translations.Strings.InvalidFolderPath, MessageBoxButton.OK, MessageBoxImage.Error);

if (Settings.Default.VerboseErrors)
{
MessageBox.Show(this, ex.ToString(), Translations.Strings.VerboseErrorOutput, MessageBoxButton.OK, MessageBoxImage.Error);
}

return;
}
}

ChatDownloadOptions chatOptions = MainWindow.pageChatDownload.GetOptions(null);
Expand Down Expand Up @@ -387,7 +429,21 @@ private void btnQueue_Click(object sender, RoutedEventArgs e)
string folderPath = textFolder.Text;
if (!Directory.Exists(folderPath))
{
TwitchHelper.CreateDirectory(folderPath);
try
{
TwitchHelper.CreateDirectory(folderPath);
}
catch (Exception ex)
{
MessageBox.Show(this, Translations.Strings.InvalidFolderPathMessage, Translations.Strings.InvalidFolderPath, MessageBoxButton.OK, MessageBoxImage.Error);

if (Settings.Default.VerboseErrors)
{
MessageBox.Show(this, ex.ToString(), Translations.Strings.VerboseErrorOutput, MessageBoxButton.OK, MessageBoxImage.Error);
}

return;
}
}

ChatUpdateOptions chatOptions = MainWindow.pageChatUpdate.GetOptions(null);
Expand Down Expand Up @@ -423,7 +479,21 @@ private void btnQueue_Click(object sender, RoutedEventArgs e)
{
if (!Directory.Exists(folderPath))
{
TwitchHelper.CreateDirectory(folderPath);
try
{
TwitchHelper.CreateDirectory(folderPath);
}
catch (Exception ex)
{
MessageBox.Show(this, Translations.Strings.InvalidFolderPathMessage, Translations.Strings.InvalidFolderPath, MessageBoxButton.OK, MessageBoxImage.Error);

if (Settings.Default.VerboseErrors)
{
MessageBox.Show(this, ex.ToString(), Translations.Strings.VerboseErrorOutput, MessageBoxButton.OK, MessageBoxImage.Error);
}

return;
}
}

string fileFormat = chatRenderPage.comboFormat.SelectedItem.ToString()!;
Expand Down Expand Up @@ -466,7 +536,21 @@ private void EnqueueDataList()
string folderPath = textFolder.Text;
if (!Directory.Exists(folderPath))
{
TwitchHelper.CreateDirectory(folderPath);
try
{
TwitchHelper.CreateDirectory(folderPath);
}
catch (Exception ex)
{
MessageBox.Show(this, Translations.Strings.InvalidFolderPathMessage, Translations.Strings.InvalidFolderPath, MessageBoxButton.OK, MessageBoxImage.Error);

if (Settings.Default.VerboseErrors)
{
MessageBox.Show(this, ex.ToString(), Translations.Strings.VerboseErrorOutput, MessageBoxButton.OK, MessageBoxImage.Error);
}

return;
}
}

foreach (var taskData in _dataList)
Expand Down Expand Up @@ -624,11 +708,18 @@ private void btnFolder_Click(object sender, RoutedEventArgs e)
if (dialog.ShowDialog(this).GetValueOrDefault())
{
textFolder.Text = dialog.SelectedPath;
Settings.Default.QueueFolder = textFolder.Text;
Settings.Default.Save();
}
}

private void TextFolder_OnTextChanged(object sender, TextChangedEventArgs e)
{
if (!IsInitialized)
return;

Settings.Default.QueueFolder = textFolder.Text;
Settings.Default.Save();
}

private void checkChat_Checked(object sender, RoutedEventArgs e)
{
checkRender.IsEnabled = true;
Expand Down
Loading