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)
| 143 | // version is a delete-marker then it will return ErrBlobNotFound. The |
| 144 | // PutOptions retention parameters will be respected when storing the object. |
| 145 | func (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. |