mirror of
https://github.com/minio/minio.git
synced 2025-04-08 21:55:44 -04:00
erasure: waitCloser should implement CloseWithError. (#1543)
This is needed so that the other end of the pipe receives and error, cleanups temporary files.
This commit is contained in:
parent
a8fdd04e62
commit
90ea494338
@ -144,9 +144,9 @@ func safeCloseAndRemove(writer io.WriteCloser) error {
|
|||||||
if ok {
|
if ok {
|
||||||
return safeWriter.CloseAndRemove()
|
return safeWriter.CloseAndRemove()
|
||||||
}
|
}
|
||||||
pipeWriter, ok := writer.(*io.PipeWriter)
|
wCloser, ok := writer.(*waitCloser)
|
||||||
if ok {
|
if ok {
|
||||||
return pipeWriter.CloseWithError(errors.New("Close and error out."))
|
return wCloser.CloseWithError(errors.New("Close and error out."))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,16 @@ func (b *waitCloser) Close() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CloseWithError closes the writer; subsequent read to the read
|
||||||
|
// half of the pipe will return the error err.
|
||||||
|
func (b *waitCloser) CloseWithError(err error) error {
|
||||||
|
w, ok := b.writer.(*io.PipeWriter)
|
||||||
|
if ok {
|
||||||
|
return w.CloseWithError(err)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// release the Close, causing it to unblock. Only call this
|
// release the Close, causing it to unblock. Only call this
|
||||||
// once. Calling it multiple times results in a panic.
|
// once. Calling it multiple times results in a panic.
|
||||||
func (b *waitCloser) release() {
|
func (b *waitCloser) release() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user