DeleteObject deletes an object by id
(id string)
| 196 | |
| 197 | // DeleteObject deletes an object by id |
| 198 | func (c *Cache) DeleteObject(id string) error { |
| 199 | err := c.db.Update(func(tx *bolt.Tx) error { |
| 200 | b := tx.Bucket(bObjects) |
| 201 | object, _ := boltGetObject(tx, id) |
| 202 | if nil == object { |
| 203 | return nil |
| 204 | } |
| 205 | |
| 206 | b.Delete([]byte(id)) |
| 207 | |
| 208 | // Remove object ids from the index |
| 209 | b = tx.Bucket(bParents) |
| 210 | for _, parent := range object.Parents { |
| 211 | b.Delete([]byte(parent + "/" + object.Name)) |
| 212 | } |
| 213 | |
| 214 | return nil |
| 215 | }) |
| 216 | if nil != err { |
| 217 | Log.Debugf("%v", err) |
| 218 | return fmt.Errorf("Could not delete object %v", id) |
| 219 | } |
| 220 | |
| 221 | return nil |
| 222 | } |
| 223 | |
| 224 | // UpdateObject updates an object |
| 225 | func (c *Cache) UpdateObject(object *APIObject) error { |
no test coverage detected