Fix: batch cleanup of temporary audio files on exit - #11
Conversation
41c7163 to
f7eac35
Compare
|
Thank you for your submission. The current master branch already includes a cleanup mechanism for historical audio files on startup. This approach also covers edge cases such as crashes and forced terminations where the Closing event cannot be triggered, and works sufficiently well as a low-frequency fallback solution. By contrast, this PR introduces the AudioTempFileTracker class, locking logic, PlaybackStopped callbacks, and bulk cleanup on exit — the added state management and lifecycle complexity outweigh the actual benefits. The current implementation also carries additional risks:
I recommend not merging this session-level file tracking solution, and retaining the existing startup fallback cleanup in the master branch instead. If further improvements to the audio logic are needed, a separate, smaller PR can be created to address only the following issues:
Given the typical file size and growth rate of these temporary audio files, this streamlined implementation will be simpler and better aligned with real-world requirements. |
Problem
Previously, temporary audio files were deleted immediately after being downloaded, which could interfere with playback. Additionally, the session cleanup logic in
MainWindow_Closingwas not actually wired to theClosingevent, so temp files were never cleaned up on exit.Solution
AudioTempFileTrackerto track downloaded audio temp files during the session.CleanupAll().MainWindow_Closingevent subscription so cleanup actually runs.Input,Output,Game,Size) discovered while testing the audio flow.Changes
GI-Subtitles/Services/Audio/AudioTempFileTracker.cs(new)GI-Subtitles/Views/MainWindow.xaml.csGI-Subtitles/Views/SettingsWindow.xaml.csGI-Test/AudioTempFileTrackerTests.cs(new).gitignoreTesting
AudioTempFileTracker; all pass.