Delete removes a stored object from the index given its identifier, it will return the removed object itself if found, or nil. This operation will also remove the object data file from disk.
(id uint64)
| 199 | // it will return the removed object itself if found, or nil. |
| 200 | // This operation will also remove the object data file from disk. |
| 201 | func (i *Index) Delete(id uint64) proto.Message { |
| 202 | i.Lock() |
| 203 | defer i.Unlock() |
| 204 | |
| 205 | record, found := i.index[id] |
| 206 | if !found { |
| 207 | return nil |
| 208 | } |
| 209 | |
| 210 | delete(i.index, id) |
| 211 | |
| 212 | os.Remove(i.pathForID(id)) |
| 213 | |
| 214 | return record |
| 215 | } |