ensures we don't open a file to close it (#1279)

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Crypt Keeper
2023-03-24 00:20:06 +01:00
committed by GitHub
parent 4eba21372c
commit 244c5c5792

View File

@@ -142,15 +142,11 @@ func (r *lazyDir) Read(p []byte) (n int, err error) {
// Close implements fs.File
func (r *lazyDir) Close() error {
f, errno := r.file()
switch errno {
case 0:
return f.Close()
case syscall.ENOENT:
return nil
default:
return errno
f := r.f
if f == nil {
return nil // never opened
}
return f.Close()
}
// FileEntry maps a path to an open file in a file system.