MCPcopy
hub / github.com/rclone/rclone / NewObjectHandle

Function NewObjectHandle

backend/cache/handle.go:63–82  ·  view source on GitHub ↗

NewObjectHandle returns a new Handle for an existing Object

(ctx context.Context, o *Object, cfs *Fs)

Source from the content-addressed store, hash-verified

61
62// NewObjectHandle returns a new Handle for an existing Object
63func NewObjectHandle(ctx context.Context, o *Object, cfs *Fs) *Handle {
64 r := &Handle{
65 ctx: ctx,
66 cachedObject: o,
67 cfs: cfs,
68 offset: 0,
69 preloadOffset: -1, // -1 to trigger the first preload
70
71 UseMemory: !cfs.opt.ChunkNoMemory,
72 reading: false,
73 }
74 r.seenOffsets = make(map[int64]bool)
75 r.memory = NewMemory(-1)
76
77 // create a larger buffer to queue up requests
78 r.preloadQueue = make(chan int64, r.cfs.opt.TotalWorkers*10)
79 r.confirmReading = make(chan bool)
80 r.startReadWorkers()
81 return r
82}
83
84// cacheFs is a convenience method to get the parent cache FS of the object's manager
85func (r *Handle) cacheFs() *Fs {

Callers 2

rcFetchMethod · 0.85
OpenMethod · 0.85

Calls 2

startReadWorkersMethod · 0.95
NewMemoryFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…