forked from Elara6331/itd
Ensure Close is always called
This commit is contained in:
parent
1a5970a041
commit
afaa5990c4
11
fuse/main.go
11
fuse/main.go
@ -246,6 +246,11 @@ func (fh *bytesFileWriteHandle) Flush(ctx context.Context) (errno syscall.Errno)
|
|||||||
fp.Close()
|
fp.Close()
|
||||||
return syscall.EROFS
|
return syscall.EROFS
|
||||||
}
|
}
|
||||||
|
err = fp.Close()
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Flush failed: close").Str("path", fh.path).Err(err).Send()
|
||||||
|
return syscall.EROFS
|
||||||
|
}
|
||||||
log.Info("Flush done").Str("path", fh.path).Int("size", len(fh.content)).Send()
|
log.Info("Flush done").Str("path", fh.path).Int("size", len(fh.content)).Send()
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@ -303,6 +308,12 @@ func (f *ITNode) Open(ctx context.Context, openFlags uint32) (fh fs.FileHandle,
|
|||||||
nread, err := fp.Read(buf)
|
nread, err := fp.Read(buf)
|
||||||
if err != nil || nread != int(f.self.size) {
|
if err != nil || nread != int(f.self.size) {
|
||||||
log.Error("Reading file failed").Str("path", f.path).Err(err).Send();
|
log.Error("Reading file failed").Str("path", f.path).Err(err).Send();
|
||||||
|
fp.Close()
|
||||||
|
return nil, 0, syscall.EROFS
|
||||||
|
}
|
||||||
|
err = fp.Close()
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Closing file failed").Str("path", f.path).Err(err).Send();
|
||||||
return nil, 0, syscall.EROFS
|
return nil, 0, syscall.EROFS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user