From 8502d4429f3ec2495c0cb03355741921c8bba364 Mon Sep 17 00:00:00 2001 From: Yami Odymel Date: Wed, 25 Jun 2025 06:14:48 +0800 Subject: [PATCH] Reverted ch.File = nil in Cleanup, to keep filename displayed --- channel/channel_file.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/channel/channel_file.go b/channel/channel_file.go index 41ba5df..fd71246 100644 --- a/channel/channel_file.go +++ b/channel/channel_file.go @@ -2,6 +2,7 @@ package channel import ( "bytes" + "errors" "fmt" "html/template" "os" @@ -49,14 +50,13 @@ func (ch *Channel) Cleanup() error { defer func() { ch.Filesize = 0 ch.Duration = 0 - ch.File = nil }() // Sync the file to ensure data is written to disk - if err := ch.File.Sync(); err != nil { + if err := ch.File.Sync(); err != nil && !errors.Is(err, os.ErrClosed) { return fmt.Errorf("sync file: %w", err) } - if err := ch.File.Close(); err != nil { + if err := ch.File.Close(); err != nil && !errors.Is(err, os.ErrClosed) { return fmt.Errorf("close file: %w", err) }