forked from Elara6331/itd
4. Better error handling
This commit is contained in:
parent
a27cc090dd
commit
9b9ab67217
9
fuse.go
9
fuse.go
@ -256,6 +256,10 @@ func (fh *bytesFileWriteHandle) Write(ctx context.Context, data []byte, off int6
|
|||||||
|
|
||||||
var _ = (fs.FileFlusher)((*bytesFileWriteHandle)(nil))
|
var _ = (fs.FileFlusher)((*bytesFileWriteHandle)(nil))
|
||||||
func (fh *bytesFileWriteHandle) Flush(ctx context.Context) (errno syscall.Errno) {
|
func (fh *bytesFileWriteHandle) Flush(ctx context.Context) (errno syscall.Errno) {
|
||||||
|
if len(fh.content) == 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
log.Info("Attempting flush").Str("path", fh.path).Send()
|
log.Info("Attempting flush").Str("path", fh.path).Send()
|
||||||
fp, err := myfs.Create(fh.path, uint32(len(fh.content)))
|
fp, err := myfs.Create(fh.path, uint32(len(fh.content)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -268,6 +272,11 @@ func (fh *bytesFileWriteHandle) Flush(ctx context.Context) (errno syscall.Errno)
|
|||||||
fp.Close()
|
fp.Close()
|
||||||
return syscall.EROFS
|
return syscall.EROFS
|
||||||
}
|
}
|
||||||
|
if int(nread) != len(fh.content) {
|
||||||
|
log.Error("Flush failed: write").Str("path", fh.path).Int("expect", len(fh.content)).Int("got", int(nread)).Send()
|
||||||
|
fp.Close()
|
||||||
|
return syscall.EROFS
|
||||||
|
}
|
||||||
err = fp.Close()
|
err = fp.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Flush failed: close").Str("path", fh.path).Err(err).Send()
|
log.Error("Flush failed: close").Str("path", fh.path).Err(err).Send()
|
||||||
|
Loading…
Reference in New Issue
Block a user