MCPcopy
hub / github.com/rclone/rclone / ObjectFromOriginal

Function ObjectFromOriginal

backend/cache/object.go:73–99  ·  view source on GitHub ↗

ObjectFromOriginal builds one from a generic fs.Object

(ctx context.Context, f *Fs, o fs.Object)

Source from the content-addressed store, hash-verified

71
72// ObjectFromOriginal builds one from a generic fs.Object
73func ObjectFromOriginal(ctx context.Context, f *Fs, o fs.Object) *Object {
74 var co *Object
75 fullRemote := cleanPath(path.Join(f.Root(), o.Remote()))
76 dir, name := path.Split(fullRemote)
77
78 cacheType := objectInCache
79 parentFs := f.UnWrap()
80 if f.opt.TempWritePath != "" {
81 _, err := f.cache.SearchPendingUpload(fullRemote)
82 if err == nil { // queued for upload
83 cacheType = objectPendingUpload
84 parentFs = f.tempFs
85 fs.Debugf(fullRemote, "pending upload found")
86 }
87 }
88
89 co = &Object{
90 ParentFs: parentFs,
91 CacheFs: f,
92 Name: cleanPath(name),
93 Dir: cleanPath(dir),
94 CacheType: cacheType,
95 CacheTs: time.Now(),
96 }
97 co.updateData(ctx, o)
98 return co
99}
100
101func (o *Object) updateData(ctx context.Context, source fs.Object) {
102 o.Object = source

Callers 8

NewObjectMethod · 0.85
ListMethod · 0.85
ListRMethod · 0.85
RmdirMethod · 0.85
DirMoveMethod · 0.85
putMethod · 0.85
CopyMethod · 0.85
MoveMethod · 0.85

Calls 8

updateDataMethod · 0.95
DebugfFunction · 0.92
cleanPathFunction · 0.85
JoinMethod · 0.80
SearchPendingUploadMethod · 0.80
RootMethod · 0.65
RemoteMethod · 0.65
UnWrapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…