HasEntry confirms the existence of a single entry (dir or object)
(remote string)
| 437 | |
| 438 | // HasEntry confirms the existence of a single entry (dir or object) |
| 439 | func (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 |
| 462 | func (b *Persistent) HasChunk(cachedObject *Object, offset int64) bool { |