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

Method Update

backend/memory/memory.go:651–676  ·  view source on GitHub ↗

Update the object with the contents of the io.Reader, modTime and size The new object may have been created if an error is returned

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

Source from the content-addressed store, hash-verified

649//
650// The new object may have been created if an error is returned
651func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (err error) {
652 bucket, bucketPath := o.split()
653 var data []byte
654 var size int64
655 var hash string
656 if o.fs.opt.Discard {
657 h := md5.New()
658 size, err = io.Copy(h, in)
659 hash = hex.EncodeToString(h.Sum(nil))
660 } else {
661 data, err = io.ReadAll(in)
662 size = int64(len(data))
663 }
664 if err != nil {
665 return fmt.Errorf("failed to update memory object: %w", err)
666 }
667 o.od = &objectData{
668 data: data,
669 size: size,
670 hash: hash,
671 modTime: src.ModTime(ctx),
672 mimeType: fs.MimeType(ctx, src),
673 }
674 buckets.updateObjectData(bucket, bucketPath, o.od)
675 return nil
676}
677
678// Remove an object
679func (o *Object) Remove(ctx context.Context) error {

Callers 1

PutMethod · 0.95

Calls 8

splitMethod · 0.95
MimeTypeFunction · 0.92
updateObjectDataMethod · 0.80
CopyMethod · 0.65
EncodeToStringMethod · 0.65
ModTimeMethod · 0.65
SumMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected