MCPcopy
hub / github.com/rclone/rclone / HasEntry

Method HasEntry

backend/cache/storage_persistent.go:439–459  ·  view source on GitHub ↗

HasEntry confirms the existence of a single entry (dir or object)

(remote string)

Source from the content-addressed store, hash-verified

437
438// HasEntry confirms the existence of a single entry (dir or object)
439func (b *Persistent) HasEntry(remote string) bool {
440 dir, name := path.Split(remote)
441 dir = cleanPath(dir)
442 name = cleanPath(name)
443
444 err := b.db.View(func(tx *bolt.Tx) error {
445 bucket := b.getBucket(dir, false, tx)
446 if bucket == nil {
447 return fmt.Errorf("couldn't open parent bucket for %v", remote)
448 }
449 if f := bucket.Bucket([]byte(name)); f != nil {
450 return nil
451 }
452 if f := bucket.Get([]byte(name)); f != nil {
453 return nil
454 }
455
456 return fmt.Errorf("couldn't find object (%v)", remote)
457 })
458 return err == nil
459}
460
461// HasChunk confirms the existence of a single chunk of an object
462func (b *Persistent) HasChunk(cachedObject *Object, offset int64) bool {

Callers 2

httpExpireRemoteMethod · 0.80

Calls 4

getBucketMethod · 0.95
cleanPathFunction · 0.85
GetMethod · 0.65
ErrorfMethod · 0.45

Tested by 1