mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 08:23:15 +01:00
suppress file already closed errors (#3695)
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
parent
5e2723187d
commit
f6605a3817
@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/anchore/syft/internal/log"
|
"github.com/anchore/syft/internal/log"
|
||||||
@ -12,6 +13,10 @@ import (
|
|||||||
// CloseAndLogError closes the given io.Closer and reports any errors found as a warning in the log
|
// CloseAndLogError closes the given io.Closer and reports any errors found as a warning in the log
|
||||||
func CloseAndLogError(closer io.Closer, location string) {
|
func CloseAndLogError(closer io.Closer, location string) {
|
||||||
if err := closer.Close(); err != nil {
|
if err := closer.Close(); err != nil {
|
||||||
|
// suppress "file already closed" log messages
|
||||||
|
if errors.Is(err, fs.ErrClosed) {
|
||||||
|
return
|
||||||
|
}
|
||||||
log.Debugf("unable to close file for location=%q: %+v", location, err)
|
log.Debugf("unable to close file for location=%q: %+v", location, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user