MCPcopy Index your code
hub / github.com/rclone/rclone / Flush

Method Flush

vfs/write.go:237–259  ·  view source on GitHub ↗

Flush is called on each close() of a file descriptor. So if a filesystem wants to return write errors in close() and the file has cached dirty data, this is a good place to write back data and return any errors. Since many applications ignore close() errors this is not always useful. NOTE: The flus

()

Source from the content-addressed store, hash-verified

235// Filesystems shouldn't assume that flush will always be called after
236// some writes, or that if will be called at all.
237func (fh *WriteFileHandle) Flush() error {
238 fh.mu.Lock()
239 defer fh.mu.Unlock()
240 if fh.closed {
241 fs.Debugf(fh.remote, "WriteFileHandle.Flush nothing to do")
242 return nil
243 }
244 // fs.Debugf(fh.remote, "WriteFileHandle.Flush")
245 // If Write hasn't been called then ignore the Flush - Release
246 // will pick it up
247 if !fh.writeCalled {
248 fs.Debugf(fh.remote, "WriteFileHandle.Flush unwritten handle, writing 0 bytes to avoid race conditions")
249 _, err := fh.writeAt([]byte{}, fh.offset)
250 return err
251 }
252 err := fh.close()
253 if err != nil {
254 fs.Errorf(fh.remote, "WriteFileHandle.Flush error: %v", err)
255 //} else {
256 // fs.Debugf(fh.remote, "WriteFileHandle.Flush OK")
257 }
258 return err
259}
260
261// Release is called when we are finished with the file handle
262//

Callers

nothing calls this directly

Calls 6

writeAtMethod · 0.95
closeMethod · 0.95
DebugfFunction · 0.92
ErrorfFunction · 0.92
LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected