MCPcopy
hub / github.com/rclone/rclone / GetChunkTs

Method GetChunkTs

backend/cache/storage_persistent.go:714–735  ·  view source on GitHub ↗

GetChunkTs retrieves the current timestamp of this chunk

(path string, offset int64)

Source from the content-addressed store, hash-verified

712
713// GetChunkTs retrieves the current timestamp of this chunk
714func (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
737func (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 {

Callers 1

TestInternalCacheWritesFunction · 0.80

Calls 5

btoiFunction · 0.85
FirstMethod · 0.80
CursorMethod · 0.65
NextMethod · 0.65
ErrorfMethod · 0.45

Tested by 1

TestInternalCacheWritesFunction · 0.64