MCPcopy
hub / github.com/rclone/rclone / AddObject

Method AddObject

backend/cache/storage_persistent.go:390–407  ·  view source on GitHub ↗

AddObject will create a cached object in its parent directory

(cachedObject *Object)

Source from the content-addressed store, hash-verified

388
389// AddObject will create a cached object in its parent directory
390func (b *Persistent) AddObject(cachedObject *Object) error {
391 return b.db.Update(func(tx *bolt.Tx) error {
392 bucket := b.getBucket(cachedObject.Dir, true, tx)
393 if bucket == nil {
394 return fmt.Errorf("couldn't open parent bucket for %v", cachedObject)
395 }
396 // cache Object Info
397 encoded, err := json.Marshal(cachedObject)
398 if err != nil {
399 return fmt.Errorf("couldn't marshal object (%v) info: %v", cachedObject, err)
400 }
401 err = bucket.Put([]byte(cachedObject.Name), encoded)
402 if err != nil {
403 return fmt.Errorf("couldn't cache object (%v) info: %v", cachedObject, err)
404 }
405 return nil
406 })
407}
408
409// RemoveObject will delete a single cached object and all the chunks which belong to it
410func (b *Persistent) RemoveObject(fp string) error {

Callers 3

ExpireObjectMethod · 0.95
ListRMethod · 0.45
persistMethod · 0.45

Calls 4

getBucketMethod · 0.95
UpdateMethod · 0.65
PutMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected