From 6acedb973ade2e2584ea2eb14b6fd91b956219b6 Mon Sep 17 00:00:00 2001 From: Gusted Date: Wed, 3 Apr 2024 14:06:39 +0200 Subject: [PATCH] Simplify delay writer Close Per https://codeberg.org/forgejo/forgejo/pulls/2983#issuecomment-1730756 --- cmd/hook.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cmd/hook.go b/cmd/hook.go index 15ed1eb7f..27efd8538 100644 --- a/cmd/hook.go +++ b/cmd/hook.go @@ -139,11 +139,10 @@ func (d *delayWriter) WriteString(s string) (n int, err error) { } func (d *delayWriter) Close() error { - if d == nil { - return nil + if d.timer.Stop() { + d.buf = nil } - stopped := d.timer.Stop() - if stopped || d.buf == nil { + if d.buf == nil { return nil } _, err := d.internal.Write(d.buf.Bytes())