mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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 <grufwub@gmail.com> * bump go-store => v2.0.7, go-mutexes => v1.1.4 Signed-off-by: kim <grufwub@gmail.com> Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
14
vendor/codeberg.org/gruf/go-store/v2/util/io.go
generated
vendored
14
vendor/codeberg.org/gruf/go-store/v2/util/io.go
generated
vendored
@@ -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()
|
||||
}
|
||||
|
Reference in New Issue
Block a user