Fix cancellation of `AudioExtractor.Extract`

fixes d3e1a6db9
This commit is contained in:
YoshiRulz 2021-11-02 21:15:24 +10:00
parent 463ef90fd2
commit a439ea4970
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 12 additions and 4 deletions

View File

@ -15,10 +15,14 @@ namespace BizHawk.Client.DiscoHawk
{
var dsr = new DiscSectorReader(disc);
bool confirmed = false;
var shouldHalt = false;
bool? overwriteExisting = null; // true = overwrite, false = skip existing (unimplemented), null = unset
var tracks = disc.Session1.Tracks;
Parallel.ForEach(tracks, track =>
{
if (shouldHalt) return;
if (!track.IsAudio)
return;
@ -37,11 +41,15 @@ namespace BizHawk.Client.DiscoHawk
string mp3Path = $"{Path.Combine(path, fileBase)} - Track {track.Number:D2}.mp3";
if (File.Exists(mp3Path))
{
if (!confirmed)
if (overwriteExisting is null)
{
var dr = MessageBox.Show("This file already exists. Do you want extraction to proceed overwriting files, or cancel the entire operation immediately?", "File already exists", MessageBoxButtons.OKCancel);
if (dr == DialogResult.Cancel) return;
confirmed = true;
if (dr == DialogResult.Cancel)
{
shouldHalt = true;
return;
}
overwriteExisting = true;
}
File.Delete(mp3Path);