MCPcopy
hub / github.com/rclone/rclone / NewObject

Function NewObject

backend/cache/object.go:43–70  ·  view source on GitHub ↗

NewObject builds one from a generic fs.Object

(f *Fs, remote string)

Source from the content-addressed store, hash-verified

41
42// NewObject builds one from a generic fs.Object
43func NewObject(f *Fs, remote string) *Object {
44 fullRemote := path.Join(f.Root(), remote)
45 dir, name := path.Split(fullRemote)
46
47 cacheType := objectInCache
48 parentFs := f.UnWrap()
49 if f.opt.TempWritePath != "" {
50 _, err := f.cache.SearchPendingUpload(fullRemote)
51 if err == nil { // queued for upload
52 cacheType = objectPendingUpload
53 parentFs = f.tempFs
54 fs.Debugf(fullRemote, "pending upload found")
55 }
56 }
57
58 co := &Object{
59 ParentFs: parentFs,
60 CacheFs: f,
61 Name: cleanPath(name),
62 Dir: cleanPath(dir),
63 CacheModTime: time.Now().UnixNano(),
64 CacheSize: 0,
65 CacheStorable: false,
66 CacheType: cacheType,
67 CacheTs: time.Now(),
68 }
69 return co
70}
71
72// ObjectFromOriginal builds one from a generic fs.Object
73func ObjectFromOriginal(ctx context.Context, f *Fs, o fs.Object) *Object {

Callers 4

httpExpireRemoteMethod · 0.70
receiveChangeNotifyMethod · 0.70
NewObjectMethod · 0.70
GetDirEntriesMethod · 0.70

Calls 6

DebugfFunction · 0.92
cleanPathFunction · 0.85
JoinMethod · 0.80
SearchPendingUploadMethod · 0.80
RootMethod · 0.65
UnWrapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…