Skip to content

Commit 6efff0a

Browse files
Refactor batch operation initialization, adjust UI defaults, and clarify skipped file handling
- Implement control disablement and `CancellationTokenSource` recreation logic at operation start. - Default `.zip` format selected for improved user experience. - Refine comments on skipped file handling for clarity and maintainability.
1 parent 5848c21 commit 6efff0a

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

BatchConvertToCompressedFile/MainWindow.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767

6868
<StackPanel Orientation="Horizontal" Margin="0,5,0,5">
6969
<Label Content="Output Format:" VerticalAlignment="Center"/>
70-
<RadioButton x:Name="Format7ZRadioButton" Content=".7z" Margin="10,0,5,0" IsChecked="True" VerticalAlignment="Center"/>
71-
<RadioButton x:Name="FormatZipRadioButton" Content=".zip" Margin="5,0,5,0" VerticalAlignment="Center"/>
70+
<RadioButton x:Name="Format7ZRadioButton" Content=".7z" Margin="10,0,5,0" VerticalAlignment="Center"/>
71+
<RadioButton x:Name="FormatZipRadioButton" Content=".zip" Margin="5,0,5,0" IsChecked="True" VerticalAlignment="Center"/>
7272
</StackPanel>
7373

7474
<CheckBox x:Name="DeleteOriginalsCheckBox" Content="Delete original files after successful compression" Margin="0,5,0,5" HorizontalAlignment="Left"/>

BatchConvertToCompressedFile/MainWindow.xaml.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,15 @@ private async void StartVerificationButton_Click(object sender, RoutedEventArgs
467467
return;
468468
}
469469

470-
if (_cts.IsCancellationRequested) _cts.Dispose();
470+
// 1. Disable controls immediately to prevent re-entry.
471+
SetControlsState(false);
472+
473+
// 2. Safely recreate the CancellationTokenSource.
474+
_cts?.Dispose();
471475
_cts = new CancellationTokenSource();
476+
477+
// 3. Reset stats and start the operation.
472478
ResetOperationStats();
473-
SetControlsState(false);
474479
_operationTimer.Restart();
475480
StartWriteSpeedTracking();
476481
UpdateStatus("Starting batch verification...");
@@ -626,7 +631,7 @@ private async Task PerformBatchCompressionAsync(string inputFolder, string outpu
626631
_failedCount++;
627632
break;
628633
case ProcessStatus.Skipped:
629-
// Do nothing, or you could add a "Skipped" counter.
634+
// Do nothing with counters for skipped files.
630635
break;
631636
}
632637

BatchConvertToCompressedFile/UpdateChecker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,4 @@ public void Dispose()
106106
_httpClient.Dispose();
107107
GC.SuppressFinalize(this);
108108
}
109-
}
109+
}

0 commit comments

Comments
 (0)