ObjectFromOriginal builds one from a generic fs.Object
(ctx context.Context, f *Fs, o fs.Object)
| 71 | |
| 72 | // ObjectFromOriginal builds one from a generic fs.Object |
| 73 | func 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 | |
| 101 | func (o *Object) updateData(ctx context.Context, source fs.Object) { |
| 102 | o.Object = source |
no test coverage detected
searching dependent graphs…