From 2554c75a8d7675ad2a087eeac7d184df7abaa11a Mon Sep 17 00:00:00 2001
From: Scrub <72096833+ScrubN@users.noreply.github.com>
Date: Sat, 3 Aug 2024 20:41:12 -0400
Subject: [PATCH] Create missing queue folder instead of erroring (#1174)

* Make missing folder instead of erroring out

* Set queue folder path regardless of existence

* Remove redundant code

* Remove unused translations
---
 .../Translations/Strings.Designer.cs          | 18 ------------
 .../Translations/Strings.es.resx              |  6 ----
 .../Translations/Strings.fr.resx              |  6 ----
 .../Translations/Strings.it.resx              |  6 ----
 .../Translations/Strings.ja.resx              |  6 ----
 .../Translations/Strings.pl.resx              |  6 ----
 .../Translations/Strings.pt-br.resx           |  6 ----
 TwitchDownloaderWPF/Translations/Strings.resx |  6 ----
 .../Translations/Strings.ru.resx              |  6 ----
 .../Translations/Strings.tr.resx              |  6 ----
 .../Translations/Strings.uk.resx              |  6 ----
 .../Translations/Strings.zh-cn.resx           |  6 ----
 .../WindowQueueOptions.xaml.cs                | 29 ++++++-------------
 13 files changed, 9 insertions(+), 104 deletions(-)

diff --git a/TwitchDownloaderWPF/Translations/Strings.Designer.cs b/TwitchDownloaderWPF/Translations/Strings.Designer.cs
index 9b2a83e4..e44a2f2a 100644
--- a/TwitchDownloaderWPF/Translations/Strings.Designer.cs
+++ b/TwitchDownloaderWPF/Translations/Strings.Designer.cs
@@ -1121,15 +1121,6 @@ public static string InvalidClipLinkIdMessage {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to Invalid Folder Path.
-        /// </summary>
-        public static string InvalidFolderPath {
-            get {
-                return ResourceManager.GetString("InvalidFolderPath", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Invalid start or end time.
         /// </summary>
@@ -1166,15 +1157,6 @@ public static string InvalidVideoLinkIdMessage {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to The folder does not exist.
-        /// </summary>
-        public static string InvaliFolderPathMessage {
-            get {
-                return ResourceManager.GetString("InvaliFolderPathMessage", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to JSON File:.
         /// </summary>
diff --git a/TwitchDownloaderWPF/Translations/Strings.es.resx b/TwitchDownloaderWPF/Translations/Strings.es.resx
index 4acc408d..099b9707 100644
--- a/TwitchDownloaderWPF/Translations/Strings.es.resx
+++ b/TwitchDownloaderWPF/Translations/Strings.es.resx
@@ -680,12 +680,6 @@
   <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="InvaliFolderPathMessage" xml:space="preserve">
-    <value>La carpeta no existe</value>
-  </data>
   <data name="StatusCanceled" xml:space="preserve">
     <value>Cancelado</value>
   </data>
diff --git a/TwitchDownloaderWPF/Translations/Strings.fr.resx b/TwitchDownloaderWPF/Translations/Strings.fr.resx
index 7c0ea914..6d700ed4 100644
--- a/TwitchDownloaderWPF/Translations/Strings.fr.resx
+++ b/TwitchDownloaderWPF/Translations/Strings.fr.resx
@@ -680,12 +680,6 @@
   <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="InvaliFolderPathMessage" xml:space="preserve">
-    <value>Le répertoire n'existe pas</value>
-  </data>
   <data name="StatusCanceled" xml:space="preserve">
     <value>Annulé</value>
   </data>
diff --git a/TwitchDownloaderWPF/Translations/Strings.it.resx b/TwitchDownloaderWPF/Translations/Strings.it.resx
index dc8b540b..3bf5a98b 100644
--- a/TwitchDownloaderWPF/Translations/Strings.it.resx
+++ b/TwitchDownloaderWPF/Translations/Strings.it.resx
@@ -680,12 +680,6 @@
   <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="InvaliFolderPathMessage" xml:space="preserve">
-    <value>La cartella non esiste</value>
-  </data>
   <data name="StatusCanceled" xml:space="preserve">
     <value>Cancellato</value>
   </data>
diff --git a/TwitchDownloaderWPF/Translations/Strings.ja.resx b/TwitchDownloaderWPF/Translations/Strings.ja.resx
index 015c1b67..d4656e38 100644
--- a/TwitchDownloaderWPF/Translations/Strings.ja.resx
+++ b/TwitchDownloaderWPF/Translations/Strings.ja.resx
@@ -680,12 +680,6 @@
   <data name="ApplicationLanguageTooltip" xml:space="preserve">
     <value>あなたの母国語でTwitchDownloaderWPFが利用できませんか?クリックで翻訳を手伝う方法を学ぶ!</value>
   </data>
-  <data name="InvalidFolderPath" xml:space="preserve">
-    <value>不正なフォルダパス</value>
-  </data>
-  <data name="InvaliFolderPathMessage" xml:space="preserve">
-    <value>フォルダが存在しません</value>
-  </data>
   <data name="StatusCanceled" xml:space="preserve">
     <value>キャンセルされた</value>
   </data>
diff --git a/TwitchDownloaderWPF/Translations/Strings.pl.resx b/TwitchDownloaderWPF/Translations/Strings.pl.resx
index fa5d6c37..bfe413bf 100644
--- a/TwitchDownloaderWPF/Translations/Strings.pl.resx
+++ b/TwitchDownloaderWPF/Translations/Strings.pl.resx
@@ -680,12 +680,6 @@
   <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="InvaliFolderPathMessage" xml:space="preserve">
-    <value>Folder nie istnieje</value>
-  </data>
   <data name="StatusCanceled" xml:space="preserve">
     <value>Anulowano</value>
   </data>
diff --git a/TwitchDownloaderWPF/Translations/Strings.pt-br.resx b/TwitchDownloaderWPF/Translations/Strings.pt-br.resx
index 2b754c6f..897d2e0c 100644
--- a/TwitchDownloaderWPF/Translations/Strings.pt-br.resx
+++ b/TwitchDownloaderWPF/Translations/Strings.pt-br.resx
@@ -680,12 +680,6 @@
   <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="InvaliFolderPathMessage" xml:space="preserve">
-    <value>A pasta não existe</value>
-  </data>
   <data name="StatusCanceled" xml:space="preserve">
     <value>Cancelado</value>
   </data>
diff --git a/TwitchDownloaderWPF/Translations/Strings.resx b/TwitchDownloaderWPF/Translations/Strings.resx
index f378f4f2..d76f0dde 100644
--- a/TwitchDownloaderWPF/Translations/Strings.resx
+++ b/TwitchDownloaderWPF/Translations/Strings.resx
@@ -680,12 +680,6 @@
   <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="InvaliFolderPathMessage" xml:space="preserve">
-    <value>The folder does not exist</value>
-  </data>
   <data name="StatusCanceled" xml:space="preserve">
     <value>Canceled</value>
   </data>
diff --git a/TwitchDownloaderWPF/Translations/Strings.ru.resx b/TwitchDownloaderWPF/Translations/Strings.ru.resx
index 9e1b0884..53d9218f 100644
--- a/TwitchDownloaderWPF/Translations/Strings.ru.resx
+++ b/TwitchDownloaderWPF/Translations/Strings.ru.resx
@@ -680,12 +680,6 @@
   <data name="ApplicationLanguageTooltip" xml:space="preserve">
     <value>TwitchDownloaderWPF не доступен на твоем языке? Нажми здесь чтобы узнать как помочь с переводом!</value>
   </data>
-  <data name="InvalidFolderPath" xml:space="preserve">
-    <value>Неправильный путь к папке</value>
-  </data>
-  <data name="InvaliFolderPathMessage" xml:space="preserve">
-    <value>Папка не существует</value>
-  </data>
   <data name="StatusCanceled" xml:space="preserve">
     <value>Отменено</value>
   </data>
diff --git a/TwitchDownloaderWPF/Translations/Strings.tr.resx b/TwitchDownloaderWPF/Translations/Strings.tr.resx
index b2aa4e33..6646a564 100644
--- a/TwitchDownloaderWPF/Translations/Strings.tr.resx
+++ b/TwitchDownloaderWPF/Translations/Strings.tr.resx
@@ -681,12 +681,6 @@
   <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="InvaliFolderPathMessage" xml:space="preserve">
-    <value>Klasör mevcut değil</value>
-  </data>
   <data name="StatusCanceled" xml:space="preserve">
     <value>İptal edildi</value>
   </data>
diff --git a/TwitchDownloaderWPF/Translations/Strings.uk.resx b/TwitchDownloaderWPF/Translations/Strings.uk.resx
index 10717467..a45c7e4d 100644
--- a/TwitchDownloaderWPF/Translations/Strings.uk.resx
+++ b/TwitchDownloaderWPF/Translations/Strings.uk.resx
@@ -680,12 +680,6 @@
   <data name="ApplicationLanguageTooltip" xml:space="preserve">
     <value>TwitchDownloaderWPF недоступно на вашій мові? Натисніть тут, щоб дізнатися, як допомогти з перекладом!</value>
   </data>
-  <data name="InvalidFolderPath" xml:space="preserve">
-    <value>Неправильний шлях до папки</value>
-  </data>
-  <data name="InvaliFolderPathMessage" xml:space="preserve">
-    <value>Папка не існує</value>
-  </data>
   <data name="StatusCanceled" xml:space="preserve">
     <value>Скасовано</value>
   </data>
diff --git a/TwitchDownloaderWPF/Translations/Strings.zh-cn.resx b/TwitchDownloaderWPF/Translations/Strings.zh-cn.resx
index 5b255566..2c59e140 100644
--- a/TwitchDownloaderWPF/Translations/Strings.zh-cn.resx
+++ b/TwitchDownloaderWPF/Translations/Strings.zh-cn.resx
@@ -680,12 +680,6 @@
   <data name="ApplicationLanguageTooltip" xml:space="preserve">
     <value>TwitchDownloaderWPF 没有你的母语版本?点击了解如何帮助翻译!</value>
   </data>
-  <data name="InvalidFolderPath" xml:space="preserve">
-    <value>文件夹路径无效</value>
-  </data>
-  <data name="InvaliFolderPathMessage" xml:space="preserve">
-    <value>文件夹不存在</value>
-  </data>
   <data name="StatusCanceled" xml:space="preserve">
     <value>已取消</value>
   </data>
diff --git a/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs b/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs
index 0d68f4e6..cd9c0259 100644
--- a/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs
+++ b/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs
@@ -5,6 +5,7 @@
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Media;
+using TwitchDownloaderCore;
 using TwitchDownloaderCore.Options;
 using TwitchDownloaderCore.Tools;
 using TwitchDownloaderWPF.Properties;
@@ -28,9 +29,7 @@ public WindowQueueOptions(Page page)
             _parentPage = page;
             InitializeComponent();
 
-            string queueFolder = Settings.Default.QueueFolder;
-            if (Directory.Exists(queueFolder))
-                textFolder.Text = queueFolder;
+            textFolder.Text = Settings.Default.QueueFolder;
 
             TextPreferredQuality.Visibility = Visibility.Collapsed;
             ComboPreferredQuality.Visibility = Visibility.Collapsed;
@@ -95,9 +94,7 @@ public WindowQueueOptions(List<TaskData> dataList)
             _dataList = dataList;
             InitializeComponent();
 
-            string queueFolder = Settings.Default.QueueFolder;
-            if (Directory.Exists(queueFolder))
-                textFolder.Text = queueFolder;
+            textFolder.Text = Settings.Default.QueueFolder;
 
             if (_dataList.Any(x => x.Id.All(char.IsDigit)))
             {
@@ -129,8 +126,7 @@ private void btnQueue_Click(object sender, RoutedEventArgs e)
                     string folderPath = textFolder.Text;
                     if (!Directory.Exists(folderPath))
                     {
-                        MessageBox.Show(this, Translations.Strings.InvaliFolderPathMessage, Translations.Strings.InvalidFolderPath, MessageBoxButton.OK, MessageBoxImage.Error);
-                        return;
+                        TwitchHelper.CreateDirectory(folderPath);
                     }
 
                     VideoDownloadOptions downloadOptions = vodDownloadPage.GetOptions(null, textFolder.Text);
@@ -230,8 +226,7 @@ private void btnQueue_Click(object sender, RoutedEventArgs e)
                     string folderPath = textFolder.Text;
                     if (!Directory.Exists(folderPath))
                     {
-                        MessageBox.Show(this, Translations.Strings.InvaliFolderPathMessage, Translations.Strings.InvalidFolderPath, MessageBoxButton.OK, MessageBoxImage.Error);
-                        return;
+                        TwitchHelper.CreateDirectory(folderPath);
                     }
 
                     ClipDownloadOptions downloadOptions = new ClipDownloadOptions
@@ -335,8 +330,7 @@ private void btnQueue_Click(object sender, RoutedEventArgs e)
                     string folderPath = textFolder.Text;
                     if (!Directory.Exists(folderPath))
                     {
-                        MessageBox.Show(this, Translations.Strings.InvaliFolderPathMessage, Translations.Strings.InvalidFolderPath, MessageBoxButton.OK, MessageBoxImage.Error);
-                        return;
+                        TwitchHelper.CreateDirectory(folderPath);
                     }
 
                     ChatDownloadOptions chatOptions = MainWindow.pageChatDownload.GetOptions(null);
@@ -393,8 +387,7 @@ private void btnQueue_Click(object sender, RoutedEventArgs e)
                     string folderPath = textFolder.Text;
                     if (!Directory.Exists(folderPath))
                     {
-                        MessageBox.Show(this, Translations.Strings.InvaliFolderPathMessage, Translations.Strings.InvalidFolderPath, MessageBoxButton.OK, MessageBoxImage.Error);
-                        return;
+                        TwitchHelper.CreateDirectory(folderPath);
                     }
 
                     ChatUpdateOptions chatOptions = MainWindow.pageChatUpdate.GetOptions(null);
@@ -430,8 +423,7 @@ private void btnQueue_Click(object sender, RoutedEventArgs e)
                     {
                         if (!Directory.Exists(folderPath))
                         {
-                            MessageBox.Show(this, Translations.Strings.InvaliFolderPathMessage, Translations.Strings.InvalidFolderPath, MessageBoxButton.OK, MessageBoxImage.Error);
-                            return;
+                            TwitchHelper.CreateDirectory(folderPath);
                         }
 
                         string fileFormat = chatRenderPage.comboFormat.SelectedItem.ToString()!;
@@ -474,8 +466,7 @@ private void EnqueueDataList()
             string folderPath = textFolder.Text;
             if (!Directory.Exists(folderPath))
             {
-                MessageBox.Show(this, Translations.Strings.InvaliFolderPathMessage, Translations.Strings.InvalidFolderPath, MessageBoxButton.OK, MessageBoxImage.Error);
-                return;
+                TwitchHelper.CreateDirectory(folderPath);
             }
 
             foreach (var taskData in _dataList)
@@ -630,8 +621,6 @@ private void EnqueueDataList()
         private void btnFolder_Click(object sender, RoutedEventArgs e)
         {
             var dialog = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog();
-            if (Directory.Exists(textFolder.Text))
-                dialog.RootFolder = dialog.RootFolder;
             if (dialog.ShowDialog(this).GetValueOrDefault())
             {
                 textFolder.Text = dialog.SelectedPath;