GetChunkTs retrieves the current timestamp of this chunk
(path string, offset int64)
| 712 | |
| 713 | // GetChunkTs retrieves the current timestamp of this chunk |
| 714 | func (b *Persistent) GetChunkTs(path string, offset int64) (time.Time, error) { |
| 715 | var t time.Time |
| 716 | |
| 717 | err := b.db.View(func(tx *bolt.Tx) error { |
| 718 | tsBucket := tx.Bucket([]byte(DataTsBucket)) |
| 719 | c := tsBucket.Cursor() |
| 720 | for k, v := c.First(); k != nil; k, v = c.Next() { |
| 721 | var ci chunkInfo |
| 722 | err := json.Unmarshal(v, &ci) |
| 723 | if err != nil { |
| 724 | continue |
| 725 | } |
| 726 | if ci.Path == path && ci.Offset == offset { |
| 727 | t = time.Unix(0, btoi(k)) |
| 728 | return nil |
| 729 | } |
| 730 | } |
| 731 | return fmt.Errorf("not found %v-%v", path, offset) |
| 732 | }) |
| 733 | |
| 734 | return t, err |
| 735 | } |
| 736 | |
| 737 | func (b *Persistent) iterateBuckets(buk *bolt.Bucket, bucketFn func(name string), kvFn func(key string, val []byte)) error { |
| 738 | err := b.db.View(func(tx *bolt.Tx) error { |