MCPcopy
hub / github.com/rclone/rclone / Update

Method Update

backend/union/entry.go:69–107  ·  view source on GitHub ↗

Update in to the object with the modTime given of the given size When called from outside an Fs by rclone, src.Size() will always be >= 0. But for unknown-sized objects (indicated by src.Size() == -1), Upload should either return an error or update the object properly (rather than e.g. calling pani

(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption)

Source from the content-addressed store, hash-verified

67// But for unknown-sized objects (indicated by src.Size() == -1), Upload should either
68// return an error or update the object properly (rather than e.g. calling panic).
69func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) error {
70 entries, err := o.fs.actionEntries(o.candidates()...)
71 if err == fs.ErrorPermissionDenied {
72 // There are no candidates in this object which can be written to
73 // So attempt to create a new object instead
74 newO, err := o.fs.put(ctx, in, src, false, options...)
75 if err != nil {
76 return err
77 }
78 // Update current object
79 o.update(newO.(*Object))
80 return nil
81 } else if err != nil {
82 return err
83 }
84 if len(entries) == 1 {
85 obj := entries[0].(*upstream.Object)
86 return obj.Update(ctx, in, src, options...)
87 }
88 // Multi-threading
89 readers, errChan := multiReader(len(entries), in)
90 errs := Errors(make([]error, len(entries)+1))
91 multithread(len(entries), func(i int) {
92 if o, ok := entries[i].(*upstream.Object); ok {
93 err := o.Update(ctx, readers[i], src, options...)
94 if err != nil {
95 errs[i] = fmt.Errorf("%s: %w", o.UpstreamFs().Name(), err)
96 if len(entries) > 1 {
97 // Drain the input buffer to allow other uploads to continue
98 _, _ = io.Copy(io.Discard, readers[i])
99 }
100 }
101 } else {
102 errs[i] = fs.ErrorNotAFile
103 }
104 })
105 errs[len(entries)] = <-errChan
106 return errs.Err()
107}
108
109// Remove candidate objects selected by ACTION policy
110func (o *Object) Remove(ctx context.Context) error {

Callers 3

TestInternalReadOnlyMethod · 0.95
PutMethod · 0.95
PutStreamMethod · 0.95

Calls 13

candidatesMethod · 0.95
updateMethod · 0.95
UpstreamFsMethod · 0.95
multiReaderFunction · 0.85
ErrorsTypeAlias · 0.85
multithreadFunction · 0.85
actionEntriesMethod · 0.80
UpdateMethod · 0.65
NameMethod · 0.65
CopyMethod · 0.65
putMethod · 0.45
ErrorfMethod · 0.45

Tested by 1

TestInternalReadOnlyMethod · 0.76