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

Method DeleteObject

drive/cache.go:198–222  ·  view source on GitHub ↗

DeleteObject deletes an object by id

(id string)

Source from the content-addressed store, hash-verified

196
197// DeleteObject deletes an object by id
198func (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
225func (c *Cache) UpdateObject(object *APIObject) error {

Callers 2

checkChangesMethod · 0.80
RemoveMethod · 0.80

Calls 1

boltGetObjectFunction · 0.85

Tested by

no test coverage detected