Reverted ch.File = nil in Cleanup, to keep filename displayed

This commit is contained in:
Yami Odymel 2025-06-25 06:14:48 +08:00
parent b8205a1b56
commit 8502d4429f
No known key found for this signature in database
GPG Key ID: 68E469836934DB36

View File

@ -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)
}