Skip to content

Commit 8ec6ca5

Browse files
committed
Bug fixes
- 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
1 parent 44451ba commit 8ec6ca5

File tree

5 files changed

+52
-13
lines changed

5 files changed

+52
-13
lines changed

changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
~ v2.0.1
2+
- Fixed an issue where an entire media buffer would crash if one file failed to process
3+
- Fixed an error when trying to delete files from the search listbox
4+
15
~ v2.0.0
26
- Switched to stable-ts for transcribing (a fork of whisper that provides more features)
37
- Switched from .NET Framework to .NET Core (an up-to-date version of .NET)

src/Scribe/Scribe/MainMenu.cs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,34 @@ private void ProcessCleanButton_Click(object sender, EventArgs e)
232232
return;
233233
}
234234

235+
DialogResult cleanModePrompt = MessageBox.Show("Do you want to clean all empty files?", "", MessageBoxButtons.YesNo);
236+
bool cleanEmpty = cleanModePrompt == DialogResult.Yes;
237+
235238
string[] storageFiles = Directory.GetFiles("Scribe\\storage", "*.scstore");
236239
int storageClean = 0;
237240

238241
for (int i = 0; i < storageFiles.Length; i++)
239242
{
240-
string storeFile = File.ReadAllText(storageFiles[i]);
241-
string[] mediaPath = storeFile.Split('\n', 2, StringSplitOptions.None);
243+
string storeFileRaw = File.ReadAllText(storageFiles[i]);
244+
string[] storeFile = storeFileRaw.Split('\n', 2, StringSplitOptions.None);
245+
246+
bool deleteCurrent = !File.Exists(storeFile[0]) || storeFile.Length != 2;
242247

243-
if (!File.Exists(mediaPath[0]) || mediaPath.Length != 2)
248+
if (storeFile.Length > 1)
249+
{
250+
// delete file if it is empty
251+
if (cleanEmpty && String.IsNullOrEmpty(storeFile[1]))
252+
{
253+
deleteCurrent = true;
254+
}
255+
}
256+
else
257+
{
258+
// delete file if it is null, no matter what
259+
deleteCurrent = true;
260+
}
261+
262+
if (deleteCurrent)
244263
{
245264
File.Delete(storageFiles[i]);
246265
storageClean++;
@@ -648,7 +667,7 @@ private void UpdateSearch()
648667
}
649668

650669
stopwatch.Stop();
651-
670+
652671
SearchSecondsLabel.Text = $"in {(stopwatch.Elapsed.TotalMilliseconds / 1000).ToString("F3")} seconds";
653672
SearchSecondsLabel.Location = new Point(238 - (SearchSecondsLabel.Width - 88), SearchSecondsLabel.Location.Y);
654673
}
@@ -690,7 +709,10 @@ private void SearchResultsListBox_KeyDown(object sender, KeyEventArgs e)
690709
SearchResultsListBox.Items.Remove(SearchResultsListBox.SelectedItem);
691710
}
692711

693-
SearchResultsListBox.SelectedIndex = 0;
712+
if (SearchResultsListBox.Items.Count > 0)
713+
{
714+
SearchResultsListBox.SelectedIndex = 0;
715+
}
694716
}
695717
}
696718

src/Scribe/Scribe/Scripts/Global.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
{
33
public static class Global
44
{
5-
public const string VERSION = "v2.0.0";
5+
public const string VERSION = "v2.0.1";
66
}
77
}

src/Scribe/Scribe/Scripts/Media/MediaProcessor.cs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,30 @@ public void Start()
6262

6363
StartNoOverheadProcess(ffmpegProcessCommand, isDebug);
6464

65-
wavSb.Append($"\"Scribe\\storage\\_temp\\{mediaQueueName}.wav\" ");
66-
srtSb.Append($"\"Scribe\\storage\\_temp\\{mediaQueueName}.srt\" ");
67-
wavFiles[i] = $"Scribe\\storage\\_temp\\{mediaQueueName}.wav";
68-
srtFiles[i] = $"Scribe\\storage\\_temp\\{mediaQueueName}.srt";
65+
string wavFile = $"Scribe\\storage\\_temp\\{mediaQueueName}.wav";
66+
string srtFile = $"Scribe\\storage\\_temp\\{mediaQueueName}.srt";
67+
68+
if (File.Exists(wavFile))
69+
{
70+
wavSb.Append($"\"{wavFile}\" ");
71+
srtSb.Append($"\"{srtFile}\" ");
72+
}
73+
74+
wavFiles[i] = wavFile;
75+
srtFiles[i] = srtFile;
6976
mediaQueueNames[i] = mediaQueueName;
7077
mediaQueueMediaPaths[i] = mediaQueuePath;
7178
}
7279

73-
wavSb.Length--;
74-
srtSb.Length--;
80+
if (wavSb.Length > 0)
81+
{
82+
wavSb.Length--;
83+
}
84+
85+
if (srtSb.Length > 0)
86+
{
87+
srtSb.Length--;
88+
}
7589

7690
string wavFilesPack = wavSb.ToString();
7791
string srtFilesPack = srtSb.ToString();

to-do.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
- Fix error when deleting a store file when there is only 1 displayed in the search listbox (caused by setting the selected index)

0 commit comments

Comments
 (0)