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

Method Open

backend/sugarsync/sugarsync.go:1201–1221  ·  view source on GitHub ↗

Open an object for read

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

Source from the content-addressed store, hash-verified

1199
1200// Open an object for read
1201func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.ReadCloser, err error) {
1202 if o.id == "" {
1203 return nil, errors.New("can't download - no id")
1204 }
1205 fs.FixRangeOption(options, o.size)
1206 var resp *http.Response
1207 opts := rest.Opts{
1208 Method: "GET",
1209 RootURL: o.id,
1210 Path: "/data",
1211 Options: options,
1212 }
1213 err = o.fs.pacer.Call(func() (bool, error) {
1214 resp, err = o.fs.srv.Call(ctx, &opts)
1215 return shouldRetry(ctx, resp, err)
1216 })
1217 if err != nil {
1218 return nil, err
1219 }
1220 return resp.Body, err
1221}
1222
1223// createFile makes an (empty) file with pathID as parent and name leaf and returns the ID
1224func (f *Fs) createFile(ctx context.Context, pathID, leaf, mimeType string) (newID string, err error) {

Callers

nothing calls this directly

Calls 3

FixRangeOptionFunction · 0.92
shouldRetryFunction · 0.70
CallMethod · 0.45

Tested by

no test coverage detected