1
mirror of https://github.com/rclone/rclone synced 2024-11-01 21:49:35 +01:00

mount: Fix read flushing - fixes #638

This commit is contained in:
Nick Craig-Wood 2016-09-10 22:32:30 +01:00
parent 265f5b77a7
commit 392a86f585
2 changed files with 18 additions and 12 deletions

View File

@ -116,17 +116,23 @@ func (fh *ReadFileHandle) Flush(ctx context.Context, req *fuse.FlushRequest) err
fh.mu.Lock()
defer fh.mu.Unlock()
fs.Debug(fh.o, "ReadFileHandle.Flush")
// If Read hasn't been called then ignore the Flush - Release
// will pick it up
if !fh.readCalled {
fs.Debug(fh.o, "ReadFileHandle.Flush ignoring flush on unread handle")
return nil
}
err := fh.close()
if err != nil {
fs.ErrorLog(fh.o, "ReadFileHandle.Flush error: %v", err)
return err
// Ignore the Flush as there is nothing we can sensibly do and
// it seems quite common for Flush to be called from
// different threads each of which have read some data.
if false {
// If Read hasn't been called then ignore the Flush - Release
// will pick it up
if !fh.readCalled {
fs.Debug(fh.o, "ReadFileHandle.Flush ignoring flush on unread handle")
return nil
}
err := fh.close()
if err != nil {
fs.ErrorLog(fh.o, "ReadFileHandle.Flush error: %v", err)
return err
}
}
fs.Debug(fh.o, "ReadFileHandle.Flush OK")
return nil

View File

@ -72,9 +72,9 @@ func TestReadFileDoubleClose(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, 1, n)
// close the dup - should produce an error
// close the dup - should not produce an error
err = syscall.Close(fd2)
assert.Error(t, err, "input/output error")
assert.NoError(t, err, "input/output error")
run.rm(t, "testdoubleclose")
}