MCPcopy
hub / github.com/rclone/rclone / Open

Method Open

backend/union/entry.go:188–204  ·  view source on GitHub ↗

Open opens the file for read. Call Close() on the returned io.ReadCloser

(ctx context.Context, options ...fs.OpenOption)

Source from the content-addressed store, hash-verified

186
187// Open opens the file for read. Call Close() on the returned io.ReadCloser
188func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadCloser, error) {
189 // Need some sort of locking to prevent multiple downloads
190 o.writebackMu.Lock()
191 defer o.writebackMu.Unlock()
192
193 // FIXME what if correct object is already in o.co
194
195 newObj, err := o.Object.Writeback(ctx)
196 if err != nil {
197 return nil, err
198 }
199 if newObj != nil {
200 o.Object = newObj
201 o.co = append(o.co, newObj) // FIXME should this append or overwrite or update?
202 }
203 return o.Object.Object.Open(ctx, options...)
204}
205
206// ModTime returns the modification date of the directory
207// It returns the latest ModTime of all candidates

Callers

nothing calls this directly

Calls 4

WritebackMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65
OpenMethod · 0.65

Tested by

no test coverage detected