diff --git a/changelog.txt b/changelog.txt index 30cac5e..7a01c88 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +~ v2.0.1 +- Fixed an issue where an entire media buffer would crash if one file failed to process +- Fixed an error when trying to delete files from the search listbox + ~ v2.0.0 - Switched to stable-ts for transcribing (a fork of whisper that provides more features) - Switched from .NET Framework to .NET Core (an up-to-date version of .NET) diff --git a/src/Scribe/Scribe/MainMenu.cs b/src/Scribe/Scribe/MainMenu.cs index 87216c9..73ffad5 100644 --- a/src/Scribe/Scribe/MainMenu.cs +++ b/src/Scribe/Scribe/MainMenu.cs @@ -232,15 +232,34 @@ private void ProcessCleanButton_Click(object sender, EventArgs e) return; } + DialogResult cleanModePrompt = MessageBox.Show("Do you want to clean all empty files?", "", MessageBoxButtons.YesNo); + bool cleanEmpty = cleanModePrompt == DialogResult.Yes; + string[] storageFiles = Directory.GetFiles("Scribe\\storage", "*.scstore"); int storageClean = 0; for (int i = 0; i < storageFiles.Length; i++) { - string storeFile = File.ReadAllText(storageFiles[i]); - string[] mediaPath = storeFile.Split('\n', 2, StringSplitOptions.None); + string storeFileRaw = File.ReadAllText(storageFiles[i]); + string[] storeFile = storeFileRaw.Split('\n', 2, StringSplitOptions.None); + + bool deleteCurrent = !File.Exists(storeFile[0]) || storeFile.Length != 2; - if (!File.Exists(mediaPath[0]) || mediaPath.Length != 2) + if (storeFile.Length > 1) + { + // delete file if it is empty + if (cleanEmpty && String.IsNullOrEmpty(storeFile[1])) + { + deleteCurrent = true; + } + } + else + { + // delete file if it is null, no matter what + deleteCurrent = true; + } + + if (deleteCurrent) { File.Delete(storageFiles[i]); storageClean++; @@ -648,7 +667,7 @@ private void UpdateSearch() } stopwatch.Stop(); - + SearchSecondsLabel.Text = $"in {(stopwatch.Elapsed.TotalMilliseconds / 1000).ToString("F3")} seconds"; SearchSecondsLabel.Location = new Point(238 - (SearchSecondsLabel.Width - 88), SearchSecondsLabel.Location.Y); } @@ -690,7 +709,10 @@ private void SearchResultsListBox_KeyDown(object sender, KeyEventArgs e) SearchResultsListBox.Items.Remove(SearchResultsListBox.SelectedItem); } - SearchResultsListBox.SelectedIndex = 0; + if (SearchResultsListBox.Items.Count > 0) + { + SearchResultsListBox.SelectedIndex = 0; + } } } diff --git a/src/Scribe/Scribe/Scripts/Global.cs b/src/Scribe/Scribe/Scripts/Global.cs index ad68235..3ba14e9 100644 --- a/src/Scribe/Scribe/Scripts/Global.cs +++ b/src/Scribe/Scribe/Scripts/Global.cs @@ -2,6 +2,6 @@ { public static class Global { - public const string VERSION = "v2.0.0"; + public const string VERSION = "v2.0.1"; } } \ No newline at end of file diff --git a/src/Scribe/Scribe/Scripts/Media/MediaProcessor.cs b/src/Scribe/Scribe/Scripts/Media/MediaProcessor.cs index 83defe1..972980e 100644 --- a/src/Scribe/Scribe/Scripts/Media/MediaProcessor.cs +++ b/src/Scribe/Scribe/Scripts/Media/MediaProcessor.cs @@ -62,16 +62,30 @@ public void Start() StartNoOverheadProcess(ffmpegProcessCommand, isDebug); - wavSb.Append($"\"Scribe\\storage\\_temp\\{mediaQueueName}.wav\" "); - srtSb.Append($"\"Scribe\\storage\\_temp\\{mediaQueueName}.srt\" "); - wavFiles[i] = $"Scribe\\storage\\_temp\\{mediaQueueName}.wav"; - srtFiles[i] = $"Scribe\\storage\\_temp\\{mediaQueueName}.srt"; + string wavFile = $"Scribe\\storage\\_temp\\{mediaQueueName}.wav"; + string srtFile = $"Scribe\\storage\\_temp\\{mediaQueueName}.srt"; + + if (File.Exists(wavFile)) + { + wavSb.Append($"\"{wavFile}\" "); + srtSb.Append($"\"{srtFile}\" "); + } + + wavFiles[i] = wavFile; + srtFiles[i] = srtFile; mediaQueueNames[i] = mediaQueueName; mediaQueueMediaPaths[i] = mediaQueuePath; } - wavSb.Length--; - srtSb.Length--; + if (wavSb.Length > 0) + { + wavSb.Length--; + } + + if (srtSb.Length > 0) + { + srtSb.Length--; + } string wavFilesPack = wavSb.ToString(); string srtFilesPack = srtSb.ToString(); diff --git a/to-do.txt b/to-do.txt index 42117b2..e69de29 100644 --- a/to-do.txt +++ b/to-do.txt @@ -1 +0,0 @@ -- Fix error when deleting a store file when there is only 1 displayed in the search listbox (caused by setting the selected index) \ No newline at end of file