Sync commits the current contents of the file to stable storage. Typically, this means flushing the file system's in-memory copy of recently written data to disk.
()
| 414 | // this means flushing the file system's in-memory copy of recently written |
| 415 | // data to disk. |
| 416 | func (fh *RWFileHandle) Sync() error { |
| 417 | fh.mu.Lock() |
| 418 | defer fh.mu.Unlock() |
| 419 | if fh.closed { |
| 420 | return ECLOSED |
| 421 | } |
| 422 | if !fh.opened { |
| 423 | return nil |
| 424 | } |
| 425 | if fh.readOnly() { |
| 426 | return nil |
| 427 | } |
| 428 | return fh.item.Sync() |
| 429 | } |
| 430 | |
| 431 | func (fh *RWFileHandle) logPrefix() string { |
| 432 | return fmt.Sprintf("%s(%p)", fh.file.Path(), fh) |