MCPcopy Index your code
hub / github.com/plexdrive/plexdrive / boltUpdateObject

Function boltUpdateObject

drive/cache.go:259–281  ·  view source on GitHub ↗
(tx *bolt.Tx, object *APIObject)

Source from the content-addressed store, hash-verified

257}
258
259func 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
283func (c *Cache) BatchUpdateObjects(objects []*APIObject) error {
284 err := c.db.Update(func(tx *bolt.Tx) error {

Callers 2

UpdateObjectMethod · 0.85
BatchUpdateObjectsMethod · 0.85

Calls 2

boltGetObjectFunction · 0.85
boltStoreObjectFunction · 0.85

Tested by

no test coverage detected