From 7c0bbd3f6a3ed9a8e5b879a00dbd4dad88e375c3 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Tue, 8 Nov 2022 09:35:01 +0000 Subject: [chore] update gruf libraries (#996) * update go-store to v2.0.6: closer callbacks are now only ever called at most once Signed-off-by: kim * bump go-store => v2.0.7, go-mutexes => v1.1.4 Signed-off-by: kim Signed-off-by: kim --- vendor/codeberg.org/gruf/go-store/v2/util/io.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'vendor/codeberg.org/gruf/go-store') diff --git a/vendor/codeberg.org/gruf/go-store/v2/util/io.go b/vendor/codeberg.org/gruf/go-store/v2/util/io.go index 334ae4dd0..3d62e8be6 100644 --- a/vendor/codeberg.org/gruf/go-store/v2/util/io.go +++ b/vendor/codeberg.org/gruf/go-store/v2/util/io.go @@ -48,6 +48,7 @@ func NopWriteCloser(w io.Writer) io.WriteCloser { } // ReadCloserWithCallback adds a customizable callback to be called upon Close() of a supplied io.ReadCloser. +// Note that the callback will never be called more than once, after execution this will remove the func reference. func ReadCloserWithCallback(rc io.ReadCloser, cb func()) io.ReadCloser { return &callbackReadCloser{ ReadCloser: rc, @@ -56,6 +57,7 @@ func ReadCloserWithCallback(rc io.ReadCloser, cb func()) io.ReadCloser { } // WriteCloserWithCallback adds a customizable callback to be called upon Close() of a supplied io.WriteCloser. +// Note that the callback will never be called more than once, after execution this will remove the func reference. func WriteCloserWithCallback(wc io.WriteCloser, cb func()) io.WriteCloser { return &callbackWriteCloser{ WriteCloser: wc, @@ -80,7 +82,11 @@ type callbackReadCloser struct { } func (c *callbackReadCloser) Close() error { - defer c.callback() + if c.callback != nil { + cb := c.callback + c.callback = nil + defer cb() + } return c.ReadCloser.Close() } @@ -91,6 +97,10 @@ type callbackWriteCloser struct { } func (c *callbackWriteCloser) Close() error { - defer c.callback() + if c.callback != nil { + cb := c.callback + c.callback = nil + defer cb() + } return c.WriteCloser.Close() } -- cgit v1.2.3