MCPcopy
hub / github.com/rclone/rclone / close

Method close

vfs/read_write.go:156–180  ·  view source on GitHub ↗

close the file handle returning EBADF if it has been closed already. Must be called with fh.mu held. Note that we leave the file around in the cache on error conditions to give the user a chance to recover it.

()

Source from the content-addressed store, hash-verified

154// Note that we leave the file around in the cache on error conditions
155// to give the user a chance to recover it.
156func (fh *RWFileHandle) close() (err error) {
157 defer log.Trace(fh.logPrefix(), "")("err=%v", &err)
158 fh.file.muRW.Lock()
159 defer fh.file.muRW.Unlock()
160
161 if fh.closed {
162 return ECLOSED
163 }
164
165 fh.closed = true
166 fh.updateSize()
167 if fh.opened {
168 err = fh.item.Close(fh.file.setObject)
169 fh.opened = false
170 } else {
171 // apply any pending mod times if any
172 _ = fh.file.applyPendingModTime()
173 }
174
175 if !fh.readOnly() {
176 fh.file.delWriter(fh)
177 }
178
179 return err
180}
181
182// Close closes the file
183func (fh *RWFileHandle) Close() error {

Callers 2

CloseMethod · 0.95
ReleaseMethod · 0.95

Calls 9

logPrefixMethod · 0.95
updateSizeMethod · 0.95
readOnlyMethod · 0.95
TraceFunction · 0.92
applyPendingModTimeMethod · 0.80
delWriterMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected