MCPcopy
hub / github.com/kopia/kopia / PutBlob

Method PutBlob

internal/blobtesting/object_locking_map.go:145–176  ·  view source on GitHub ↗

PutBlob works the same as map-storage PutBlob except that if the latest version is a delete-marker then it will return ErrBlobNotFound. The PutOptions retention parameters will be respected when storing the object.

(ctx context.Context, id blob.ID, data blob.Bytes, opts blob.PutOptions)

Source from the content-addressed store, hash-verified

143// version is a delete-marker then it will return ErrBlobNotFound. The
144// PutOptions retention parameters will be respected when storing the object.
145func (s *objectLockingMap) PutBlob(ctx context.Context, id blob.ID, data blob.Bytes, opts blob.PutOptions) error {
146 s.mutex.Lock()
147 defer s.mutex.Unlock()
148
149 var b bytes.Buffer
150 if _, err := data.WriteTo(&b); err != nil {
151 return err
152 }
153
154 e := &entry{
155 value: b.Bytes(),
156 }
157
158 if opts.SetModTime.IsZero() {
159 e.mtime = s.timeNow()
160 } else {
161 e.mtime = opts.SetModTime
162 }
163
164 if opts.HasRetentionOptions() {
165 e.retentionTime = e.mtime.Add(opts.RetentionPeriod)
166 e.retentionMode = opts.RetentionMode
167 }
168
169 s.data[id] = append(s.data[id], e)
170
171 if opts.GetModTime != nil {
172 *opts.GetModTime = e.mtime
173 }
174
175 return nil
176}
177
178// DeleteBlob will insert a delete marker after the last version of the object.
179// If the object does not exist then this becomes a no-op.

Callers

nothing calls this directly

Calls 6

HasRetentionOptionsMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65
WriteToMethod · 0.65
BytesMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected