1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-22 08:42:32 -05:00

Simplify delay writer Close

Per https://codeberg.org/forgejo/forgejo/pulls/2983#issuecomment-1730756
This commit is contained in:
Gusted 2024-04-03 14:06:39 +02:00
parent 7d35a76ebf
commit 6acedb973a
No known key found for this signature in database
GPG key ID: FD821B732837125F

View file

@ -139,11 +139,10 @@ func (d *delayWriter) WriteString(s string) (n int, err error) {
} }
func (d *delayWriter) Close() error { func (d *delayWriter) Close() error {
if d == nil { if d.timer.Stop() {
return nil d.buf = nil
} }
stopped := d.timer.Stop() if d.buf == nil {
if stopped || d.buf == nil {
return nil return nil
} }
_, err := d.internal.Write(d.buf.Bytes()) _, err := d.internal.Write(d.buf.Bytes())