Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
o7q committed Jul 25, 2024
1 parent 44451ba commit 8ec6ca5
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 13 deletions.
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
32 changes: 27 additions & 5 deletions src/Scribe/Scribe/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Scribe/Scribe/Scripts/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{
public static class Global
{
public const string VERSION = "v2.0.0";
public const string VERSION = "v2.0.1";
}
}
26 changes: 20 additions & 6 deletions src/Scribe/Scribe/Scripts/Media/MediaProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion to-do.txt
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 8ec6ca5

Please sign in to comment.