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

Method Update

backend/yandex/yandex.go:1136–1161  ·  view source on GitHub ↗

Update the already existing object Copy the reader into the object updating 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

1134//
1135// The new object may have been created if an error is returned
1136func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) error {
1137 in1 := readers.NewCountingReader(in)
1138 modTime := src.ModTime(ctx)
1139 remote := o.filePath()
1140
1141 //create full path to file before upload.
1142 err := o.fs.mkParentDirs(ctx, remote)
1143 if err != nil {
1144 return err
1145 }
1146
1147 //upload file
1148 err = o.upload(ctx, in1, true, fs.MimeType(ctx, src), options...)
1149 if err != nil {
1150 return err
1151 }
1152
1153 //if file uploaded successfully then return metadata
1154 o.modTime = modTime
1155 o.md5sum = "" // according to unit tests after put the md5 is empty.
1156 o.size = int64(in1.BytesRead()) // better solution o.readMetaData() ?
1157 //and set modTime of uploaded file
1158 err = o.SetModTime(ctx, modTime)
1159
1160 return err
1161}
1162
1163// Remove an object
1164func (o *Object) Remove(ctx context.Context) error {

Callers

nothing calls this directly

Calls 8

filePathMethod · 0.95
uploadMethod · 0.95
BytesReadMethod · 0.95
SetModTimeMethod · 0.95
NewCountingReaderFunction · 0.92
MimeTypeFunction · 0.92
ModTimeMethod · 0.65
mkParentDirsMethod · 0.45

Tested by

no test coverage detected