(tx *bolt.Tx, object *APIObject)
| 257 | } |
| 258 | |
| 259 | func boltUpdateObject(tx *bolt.Tx, object *APIObject) error { |
| 260 | prev, _ := boltGetObject(tx, object.ObjectID) |
| 261 | if nil != prev { |
| 262 | // Remove object ids from the index |
| 263 | b := tx.Bucket(bParents) |
| 264 | for _, parent := range prev.Parents { |
| 265 | b.Delete([]byte(parent + "/" + prev.Name)) |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | if err := boltStoreObject(tx, object); nil != err { |
| 270 | return err |
| 271 | } |
| 272 | |
| 273 | // Store the object id by parent-name in the index |
| 274 | b := tx.Bucket(bParents) |
| 275 | for _, parent := range object.Parents { |
| 276 | if err := b.Put([]byte(parent+"/"+object.Name), []byte(object.ObjectID)); nil != err { |
| 277 | return err |
| 278 | } |
| 279 | } |
| 280 | return nil |
| 281 | } |
| 282 | |
| 283 | func (c *Cache) BatchUpdateObjects(objects []*APIObject) error { |
| 284 | err := c.db.Update(func(tx *bolt.Tx) error { |
no test coverage detected