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

Method Open

backend/fichier/object.go:81–105  ·  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

79
80// Open opens the file for read. Call Close() on the returned io.ReadCloser
81func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadCloser, error) {
82 fs.FixRangeOption(options, o.file.Size)
83 downloadToken, err := o.fs.getDownloadToken(ctx, o.file.URL)
84
85 if err != nil {
86 return nil, err
87 }
88
89 var resp *http.Response
90 opts := rest.Opts{
91 Method: "GET",
92 RootURL: downloadToken.URL,
93 Options: options,
94 }
95
96 err = o.fs.pacer.Call(func() (bool, error) {
97 resp, err = o.fs.rest.Call(ctx, &opts)
98 return shouldRetry(ctx, resp, err)
99 })
100
101 if err != nil {
102 return nil, err
103 }
104 return resp.Body, err
105}
106
107// Update in to the object with the modTime given of the given size
108//

Callers

nothing calls this directly

Calls 4

FixRangeOptionFunction · 0.92
getDownloadTokenMethod · 0.80
shouldRetryFunction · 0.70
CallMethod · 0.45

Tested by

no test coverage detected