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

Method Open

fs/operations/multithread_test.go:255–277  ·  view source on GitHub ↗

Open opens the file for read. Call Close() on the returned io.ReadCloser Remember this is called multiple times whenever the backend seeks (eg having read checksum)

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

Source from the content-addressed store, hash-verified

253//
254// Remember this is called multiple times whenever the backend seeks (eg having read checksum)
255func (o errorObject) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadCloser, error) {
256 fs.Debugf(nil, "Open with options = %v", options)
257 rc, err := o.Object.Open(ctx, options...)
258 if err != nil {
259 return nil, err
260 }
261 // Return an error reader for the second segment
262 for _, option := range options {
263 if ropt, ok := option.(*fs.RangeOption); ok {
264 end := ropt.End + 1
265 if end >= o.size {
266 // Give the other chunks a chance to start
267 time.Sleep(time.Second)
268 // Wait for chunks to upload first
269 o.wg.Wait()
270 fs.Debugf(nil, "Returning error reader")
271 return errorReadCloser{rc}, nil
272 }
273 }
274 }
275 o.wg.Add(1)
276 return wgReadCloser{rc, o.wg}, nil
277}
278
279type errorReadCloser struct {
280 io.ReadCloser

Callers

nothing calls this directly

Calls 4

DebugfFunction · 0.92
OpenMethod · 0.65
WaitMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected