MCPcopy
hub / github.com/rclone/rclone / RemoveObject

Method RemoveObject

backend/cache/storage_persistent.go:410–426  ·  view source on GitHub ↗

RemoveObject will delete a single cached object and all the chunks which belong to it

(fp string)

Source from the content-addressed store, hash-verified

408
409// RemoveObject will delete a single cached object and all the chunks which belong to it
410func (b *Persistent) RemoveObject(fp string) error {
411 parentDir, objName := path.Split(fp)
412 return b.db.Update(func(tx *bolt.Tx) error {
413 bucket := b.getBucket(cleanPath(parentDir), false, tx)
414 if bucket == nil {
415 return fmt.Errorf("couldn't open parent bucket for %v", cleanPath(parentDir))
416 }
417 err := bucket.Delete([]byte(cleanPath(objName)))
418 if err != nil {
419 fs.Debugf(fp, "couldn't delete obj from storage: %v", err)
420 }
421 // delete chunks on disk
422 // safe to ignore as the file might not have been open
423 _ = os.RemoveAll(path.Join(b.dataPath, fp))
424 return nil
425 })
426}
427
428// ExpireObject will flush an Object and all its data if desired
429func (b *Persistent) ExpireObject(co *Object, withData bool) error {

Callers 5

ListMethod · 0.80
putMethod · 0.80
MoveMethod · 0.80
UpdateMethod · 0.80
RemoveMethod · 0.80

Calls 8

getBucketMethod · 0.95
DebugfFunction · 0.92
cleanPathFunction · 0.85
JoinMethod · 0.80
UpdateMethod · 0.65
DeleteMethod · 0.65
RemoveAllMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected